Android Custom Layout for listview

前端 未结 3 1061

I am using a list view as follows

String[] Shows = new String[] { \"Dexter\", \"Breaking Bad\", \"The Big Bang Theory\", \"Leverage\"};
ListView tv_show_lis         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 02:12

    Look at this Adding 2 buttons to the text view You basically need a custom adapter for your list and need to override the getView method of it, where you can specify the item's UI layout.

    For the code you've posted, instead of using an instance of ArrayAdapter, create your own adapter derived from ArrayAdapter YourData should be a class to contain reference to item's text and item's image.

    Now override the getView method in your custom Adapter class. The method is used to populate the UI for an item using the position argument from

    View getView(int position, View convertView, ViewGroup parent)

    You can get that item using ArrayAdapter.getItem

    For more details refer to the link above and http://developer.android.com/reference/android/widget/ArrayAdapter.html

提交回复
热议问题