Alter a custom Listview
I currently have a ListView that takes in an array of strings. It is created in the following way (in the onCreate() method):
private ArrayAdapter<String> adapter;
String[] list = getResources().getStringArray(R.array.ingredients_array);
lv = (ListView)findViewById(R.id.itemList1);
adapter =new ArrayAdapter<String>(this,R.layout.list_view_format2,R.id.l开发者_如何学Goist_content2,list);
lv.setAdapter(adapter);
R.layout.list_view_format2: a custom ListView format. It contains an ImageView and a TextView R.id.list_content2: Id of the Text View within R.id.list_view_format2
I want to access each child of ListView dynamically and compare the text(TextView) with a string. Later, I would like to modify the image(ImageView) associated with the child based on the search. Could you please help me with this? I have searched around a lot but I haven't been able to find any success.
From what i understood you need to custom the listview, in order to do this you need to create your own Adapter, there are plenty of example on how to do this.
精彩评论