首页 > 代码库 > Android ListView实现任意layout
Android ListView实现任意layout
SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.timenotes_item_left, new String[] { "text1", "text2", "text3" }, new int[] { R.id.textView2, R.id.textView3, R.id.textView4 }) { @Override public View getView(int position, View convertView, ViewGroup parent) { Map itemData = (Map) getItem(position); int type = Integer.parseInt(itemData.get("type").toString()); View itemView = null; switch (type) { case 0: Log.d("adapter", "type 0"); itemView = View.inflate(getApplicationContext(), R.layout.timenotes_item_left, null); break; case 1: Log.d("adapter", "type 1"); itemView = View.inflate(getApplicationContext(), R.layout.timenotes_item_right, null); break; default: Log.d("adapter", "type default"); break; } return itemView; } }; ListView listView = (ListView) findViewById(R.id.listView1); listView.setAdapter(adapter);
Android ListView实现任意layout
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。