Friday, 16 August 2013

ListView Item in Android?

ListView Item in Android?

I have a listview that has items from the array i.e String[] statesList =
{"Adult 1", "Adult 2","Adult 3","Child 1","Child 2","Child 1","Child
2","Child 2"};
Now i want to hide a textview if the item is clicked apart from Adult.
This is my function that i have written for populating the data in the
listview
private void showPassengerListView() {
String[] passengerList ={"Adult 1", "Adult 2","Adult 3","Child
1","Child 2","Child 1","Child 2","Child 2"};
ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1, passengerList);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
}
How to check which item has been clicked.From the listview .On the basis
of the item clicked i have to show hide a textview .Main question is how
to identify .The items will be dynamic in the listview .But have like
Adult,Child ,Infant.

No comments:

Post a Comment