开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜