April 2019
Beginner to intermediate
698 pages
15h 15m
English
Add this highlighted code to the InsertFragment class to update the onCreateView function, as follows:
val view = inflater.inflate(
R.layout.content_insert,
container,
false)
// Database and UI code goes here in next chapter
val dm = DataManager(activity!!)
val btnInsert = view.findViewById(R.id.btnInsert) as Button
val editName = view.findViewById(R.id.editName) as EditText
val editAge = view.findViewById(R.id.editAge) as EditText
btnInsert.setOnClickListener(
{
dm.insert(editName.text.toString(),
editAge.text.toString())
}
)
return viewIn the code, we get an instance of our DataManager class and a reference to each of our UI widgets. Then, in the onClick function of the button, we use ...
Read now
Unlock full access