How Do You Inflate An Xml Layout In Android?
I'm writing an android application which starts of as a listview, for which I've written a class that extends ArrayAdapter, populating each row from a database. When an Item in the
Solution 1:
For inflating you can use
public View myView()
{
View v;
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.prob3_layout, null);
return v;
}
Solution 2:
You need to create Custom Adapter to show your Values in List View. Check out this Custom List in Android
Let me know if you find any difficulty.
Solution 3:
Generally what you want to do is write another Activity (a details Activity). You will have a corresponding view (XML) to go with this activity. You pass the id of the item clicked through a Bundle. Here is another question which shows hows to pass data to another Activity (through an Intent).
So you would build a new view to show the details. In your new DetailsActivity.java that extends Activity, in your onCreate you would call setContent(R.layout.detailsView) - where R.layout.detailsView corresponds to an xml you created.
Post a Comment for "How Do You Inflate An Xml Layout In Android?"