标签:
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 }
Android-ListView-Adapter view无复用
标签:
原文地址:http://www.cnblogs.com/lude313/p/4862613.html