Android-ListView-Adapter view无复用

ListView设置适配器,加载Item视图

方法:

lvList.setAdapter(new MenuAdapter());

 

MenuAdapter类具体实现如下:

 1 class MenuAdapter extends BaseAdapter {
 2 
 3     @Overrride
 4     public int getCount(){
 5             reutrn mMenuList.size();
 6     }
 7 
 8     @Override
 9     public NewsMenuData getItem(int position) {
10             return mMenuList.get(position);
11     }
12 
13     @Override
14     public long getItemId(int position) {
15             return position;
16     }
17 
18     @Override
19     public View getView(int position, View convertView, ViewGroup parent) {
20 //此处没有复用view对象,主要是考虑到data简单,么有必要。
21             View view = View.inflate(mActivity, R.layout.list_menu_item, null);
22             TextView tvTitle = (TextView)view.findViewById(R.id.tv_title);
23             
24             NewsMenuData newsMenuData = mMenuList.get(position);
25             tvTitle.setText(newsMenuData.title);
26             return view;
27     }
28 }

 

posted @ 2015-10-08 22:54  lude313  阅读(318)  评论(0编辑  收藏  举报