WEB开发网
开发学院手机开发Android 开发 Android Listview 详解 阅读

Android Listview 详解

 2010-06-22 02:39:00 来源:WEB开发网   
核心提示:android:layout_height="wrap_content"android:text="@string/s_view_btn"android:layout_gravity="bottom|right" />< /LinearLayout

android:layout_height="wrap_content"

android:text="@string/s_view_btn"

android:layout_gravity="bottom|right" />

< /LinearLayout>

复制代码

程序代码:

/**

* @author allin

*

*/

public class MyListView4 extends ListActivity {

private List> mData;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

mData = getData();

MyAdapter adapter = new MyAdapter(this);

setListAdapter(adapter);

}

private List> getData() {

List> list = new ArrayList>();

Map map = new HashMap();

map.put("title", "G1");

map.put("info", "google 1");

map.put("img", R.drawable.i1);

list.add(map);

map = new HashMap();

map.put("title", "G2");

map.put("info", "google 2");

map.put("img", R.drawable.i2);

list.add(map);

map = new HashMap();

map.put("title", "G3");

map.put("info", "google 3");

map.put("img", R.drawable.i3);

list.add(map);

return list;

}

// ListView 中某项被选中后的逻辑

@Override

protected void onListItemClick(ListView l, View v, int position, long id) {

Log.v("MyListView4-click", (String)mData.get(position).get("title"));

}

/**

* listview中点击按键弹出对话框

*/

public void showInfo(){

new AlertDialog.Builder(this)

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android Listview 详解

编辑录入:coldstar [复制链接] [打 印]
赞助商链接