ClassCastException with ListView when executing notifyDataSetChanged

前端 未结 6 1251
醉酒成梦
醉酒成梦 2020-12-08 19:11

I have added a view to the header of listVivew,

    View TopSearch =  (View) View.inflate(this, R.layout.search, null);
    lv.addHeaderView(TopSearch, null         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 19:40

    public class YourOwnList extends ListActivity {
        private EfficientAdapter mAdapter;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            mAdapter = new EfficientAdapter(/*your parameters for the adapter*/);
        }
    
        private void yourMethod () {
            mAdapter.notifyDataSetChanged();
        }
    
        private static class EfficientAdapter extends CursorAdapter {
            // your adapter
        }
    }
    

提交回复
热议问题