Android Listview数据显示
来源:互联网 发布:手机淘宝客软件 编辑:程序博客网 时间:2024/05/01 23:52
正常充气:
lvStudents = (ListView) findViewById(R.id.lvStudent); adapter = new StudentAdapter(this, biz.getStudents()); lvStudents.setAdapter(adapter); lvData = (ListView) findViewById(R.id.lvData); adapter = new ConversationAdapter(this, biz.getConversations()); lvData.setAdapter(adapter);
特殊充气:
//CallLogListAdapter getView()方法中充气如下: if (convertView == null) { // 注意是充气是mItemLayoutResId,那就具体是在CallLogFragment中的onCreateView中充气的. convertView = mLayoutInflater.inflate(mItemLayoutResId, null); } //CallLogFragment中具体充气成功如下: List<ContactBean> contactListData = new ArrayList<ContactBean>(); mContactsListAdapter = new ContactsListAdapter(getActivity(),contactListData, R.layout.contacts_list_item_layout); mContactsListView.setAdapter(mContactsListAdapter);
listview显示数据三种方式:
1:changeData
StuMainActivity类中: private void setupView() { lvStudents = (ListView) findViewById(R.id.lvStudents); adapter = new StudentAdapter(this, null); lvStudents.setAdapter(adapter); }StudentAdapter类中: public void setStudents(ArrayList<Student> students) { if (students != null) this.students = students; else this.students = new ArrayList<Student>(); } public StudentAdapter(Context context, ArrayList<Student> students) { this.setStudents(students); this.inflater = LayoutInflater.from(context); }adapter.changeData(biz.getStudents());
2:util
MainActivity类中:
private void setupView() { this.lv1 = (ListView) findViewById(R.id.lv1); this.productService = new ProductService(); List<Product> list = this.productService.findAll(); this.adapter = new ProductAdapter(list, LayoutInflater.from(this)); lv1.setAdapter(adapter); }
ProductAdapter类中:
public ProductAdapter(List<Product> list,LayoutInflater inflater) { this.list = list; this.inflater = inflater; }
3:application
FSPointActivity类中:
user = MyApplication.getMyApplication().getUser(); private void setupView() { keywords = user.getCustomKeywords(); adapter = new PointsAdapter(this, keywords); gvPoints.setAdapter(adapter); }
PointsAdapter类中:
public void setKeywords(ArrayList<CustomKeyword> keywords) { if (keywords != null) { this.keywords = keywords; } else { this.keywords = new ArrayList<CustomKeyword>(); } } public PointsAdapter(Context context, ArrayList<CustomKeyword> keywords) { this.context = context; this.inflater = LayoutInflater.from(context); this.setKeywords(keywords); }
0 0
- android ListView数据显示
- Android ListView数据显示
- Android Listview数据显示
- Android数据的分页 listview显示数据
- android ListView没有数据时信息显示
- Android采用ListView实现数据列表显示
- Android采用ListView实现数据列表显示
- Android ListView实现分页显示数据
- Android ListView实现分页显示数据
- android listView 显示数据 单击 长按
- Android采用ListView实现数据列表显示
- Android采用ListView实现数据列表显示
- Android采用ListView实现数据列表显示
- Android采用ListView实现数据列表显示
- Android学习之ListView显示XML数据
- Android SQLite数据显示于ListView
- Android采用ListView实现数据列表显示
- android listview无限循环显示数据
- 初学最长上升子序列心得
- Android Fragment使用
- 最短路径问题
- Windows无法访问虚拟机Linux下的TomCat的解决方法
- 【Web】Javascript基础之原型链
- Android Listview数据显示
- 动态规划:最大上升子序列和
- python基于文件操作
- c实现的算法
- 程序的本质复杂性和元语言抽象
- 对象
- lightoj-1029-Civil and Evil Engineer(最小生成树+克鲁斯卡尔算法)
- js 和ajax 提交给服务器端的代码, 验证输入值符不符合,验证服务器传递过来的值 thinkphp
- Go实战--go语言中执行shell脚本(The way to go)