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);
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。