日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > 一起學android之SimpleAdapter使用(13)

一起學android之SimpleAdapter使用(13)

來源:程序員人生   發布時間:2015-01-06 08:07:42 閱讀次數:2551次

SimpleAdapter:將List集合的多個對象包裝成列表項。

我們可以通過SimpleAdapter來實現1些復雜的列表,請看以下實例:


simpleadapter_list布局文件:

<span style="font-size:18px;"><?xml version="1.0" encoding="utf⑻"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ListView android:id="@+id/lv_simpleadapter" android:layout_width="fill_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout></span>

simpleadapter布局文件:用于顯示列表項的組件

<span style="font-size:18px;"><?xml version="1.0" encoding="utf⑻"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/ll_top" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal"> <ImageView android:id="@+id/iv_image" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="fitXY" android:src="@drawable/a5i" android:layout_gravity="center"/> <LinearLayout android:id="@+id/ll_right" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginTop="4dp"> <TextView android:id="@+id/tv_title" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:text="AS"/> <TextView android:id="@+id/tv_des" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="13sp" android:text="AS" /> </LinearLayout> </LinearLayout> </RelativeLayout></span>

SimpleAdapterTest主文件:

<span style="font-size:18px;">public class SimpleAdapterTest extends Activity { int[] images = new int[] { R.drawable.a5i, R.drawable.a5j, R.drawable.a5k }; String[] titles = new String[] { "電話", "QQ", "聯系人" }; String[] des = new String[] { "當前無電話記錄", "當前無QQ聊天記錄", "最近無聯系人" }; private ListView lv_simple; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simpleadapter_list); initView(); setData(); } private void initView() { lv_simple = (ListView) findViewById(R.id.lv_simpleadapter); lv_simple.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(SimpleAdapterTest.this, titles[position], Toast.LENGTH_SHORT).show(); } }); } private void setData() { // 創建數據源 List<HashMap<String, Object>> listItems = new ArrayList<HashMap<String, Object>>(); for (int i = 0; i < titles.length; i++) { // 每一個列表項的內容 HashMap<String, Object> listItem = new HashMap<String, Object>(); listItem.put("image", images[i]); listItem.put("title", titles[i]); listItem.put("desc", des[i]); listItems.add(listItem); } /* * SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) * 參數說明: * context:全部利用的上下文。 * data:是List<? extends Map<String, ?>>的集合對象,其中每一個Map<String, ?>代表每列的列表項內容。 * resource:界面布局文件的ID。 * from:String[]類型的參數,指定了Map<String, ?>中的每一個key對應的value來生成列表項。 * to:int[]類型的參數,顯示每一個列表項顯示的組件。 */ SimpleAdapter simpleAdapter = new SimpleAdapter(SimpleAdapterTest.this, listItems, R.layout.simpleadapter, new String[] { "image", "title", "desc" }, new int[] { R.id.iv_image, R.id.tv_title, R.id.tv_des }); //綁定適配器 lv_simple.setAdapter(simpleAdapter); } }</span>







轉載請注明出處:http://blog.csdn.net/hai_qing_xu_kong/article/details/42361041  情緒控_







生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 黄动漫在线观看 | 国产美女视频 | 日韩一区电影 | 国产精品视频一二三区 | 日韩一区二区视频 | 91麻豆精品一区二区三区 | 99久久9 | 免费高清日本 | 一区二区成人在线 | 三级无遮挡污在线观看 | 亚洲精品久久久久久久久久久 | 国产精品久久久久久久免费软件 | 国产三区精品 | 99久久毛片| 国产精品欧美一区二区 | 国产精品久久久久久久av大片 | 久草免费在线视频 | 成人播放 | 91久久久国产精品 | 欧美综合网 | 9999精品| 国产在线播 | 午夜视频一区二区三区 | 成人做爰视频www网站小优视频 | 日本国产一区 | 久久精品国产一区二区三区 | a级毛片免费高清在线播放 视频精品一区二区三区 | 午夜精品一区二区三区在线播放 | 国产区视频在线 | 性欧美xxxx | 久久精品成人一区二区三区蜜臀 | 国产精品区一区二区三区 | 日本成人一区 | 一级毛片成人免费看a | 久久免费视频在线观看 | 九九av| 精品三级在线观看 | 日韩国产一区二区三区 | 亚洲一区二区黄色 | 亚洲在线中文字幕 | 91香蕉视频导航 |