I am working on my first Android App. I created an android application project and have dug through the code and It is unclear how I'm going to set separate views for each list item. The original code is as follows
On reviewing this code it is clear that the view hasn't been changed, only the content has been changed from the dummy item. I would prefer to have each dummyItem have its own view, layout, etc.
The code for establishing these views are in the dummy content
What I would like to do would be more like the following where each item would have its own view and layout.
Can someone tell me how this can be done or provide a link to a comprehensive tutorial that explains how to do this? I thought there may be some type of container I can use to swap views in and out or possibly that I may be able to grab a view from the dummy item itself, but none of the tutorials I can find show anything like this.
Code:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);
// Show the dummy content as text in a TextView.
if (mItem != null) {
((TextView) rootView.findViewById(R.id.item_detail)).setText(mItem.content);
}
return rootView;
}
The code for establishing these views are in the dummy content
Code:
static {
// Add 3 sample items.
addItem(new DummyItem("1", "Live"));
addItem(new DummyItem("2", "Settings"));
addItem(new DummyItem("3", "About"));
}
Code:
static {
// Add 3 sample items.
addItem(new LiveDummyItem("1", "Live"));
addItem(new SettingsDummyItem("2", "Settings"));
addItem(new AboutDummyItem("3", "About"));
}