Custom adapter for navigation drawer

后端 未结 2 748
别那么骄傲
别那么骄傲 2020-12-18 10:20

I have a working navigation drawer that uses ArrayAdapter as shown in the documentation. I want to set ImageView icons for each of the navigation d

2条回答
  •  北海茫月
    2020-12-18 11:02

    Updated
    1) I don't see the source of data to be displayed in your code - you don't pass it in the constructor or any other way
    2) In getView() you should set values for your Views
    3) To be efficient you have to re-use convertView if it's not null
    4) And at last - for your CustomAdapter override also following methods:

        @Override
        public int getViewTypeCount() {
       ...
        }
    
    
        @Override
        public int getItemViewType(int position) {
       ...
        }
    
        @Override
        public int getCount() {
        ...
        }
    
        @Override
        public YOUR_ITEM_TYPE getItem(int position) {
        ...
        }
    
        @Override
        public long getItemId(int position) {
        ...
        }
    
        @Override
        public boolean hasStableIds() {
        ...
        }
    
        @Override
        public boolean isEmpty() {
        ...
        }
    
        @Override
        public boolean areAllItemsEnabled() {
        ...
        }
    
        @Override
        public boolean isEnabled(int position) {
        ...
        }
    

提交回复
热议问题