android-ListActivity与HashMap的简单使用
来源:互联网 发布:excel数据下拉递增 编辑:程序博客网 时间:2024/05/17 21:44
package zhang.listActivity;import java.util.ArrayList;import java.util.HashMap;import android.app.ListActivity;import android.os.Bundle;import android.view.View;import android.widget.ListView;import android.widget.SimpleAdapter;public class listActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayList<HashMap<String,String>> list=new ArrayList<HashMap<String,String>>(); HashMap<String,String> map1= new HashMap<String,String>(); HashMap<String,String> map2= new HashMap<String,String>(); HashMap<String,String> map3= new HashMap<String,String>(); map1.put("user", "zhang"); map1.put("id", "192.168.0.0"); map2.put("user", "wang"); map2.put("id", "192.168.0.1"); map3.put("user", "li"); map3.put("id", "192.168.0.2"); list.add(map1); list.add(map2); list.add(map3); SimpleAdapter listApadter = new SimpleAdapter( this,list,R.layout.user,new String[]{"user","id"}, new int[]{R.id.user_name,R.id.user_ip}); setListAdapter(listApadter); } protected void OnListItemClick(ListView l,View v,int position,long id){ super.onListItemClick(l, v, position, id); System.out.print(id+position); } }
主布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/listLinearLayout" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" ><ListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false" android:scrollbars="vertical" /> </LinearLayout></LinearLayout>
list子项布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10pt" > <TextView android:id="@+id/user_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10pt" /> <TextView android:id="@+id/user_ip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10pt" android:gravity="right" /></LinearLayout>
- android-ListActivity与HashMap的简单使用
- android笔记--简单的listactivity的使用
- Android学习--ListActivity的简单使用以及监听事件
- Android中ListActivity的使用
- android中listactivity的使用
- ListView,ListActivity的认识及简单使用
- ListActivity与Activity的使用与区别
- Android之 ListActivity 的使用和在 ListView中添加图片文字(ListActivity与Activity的区别)
- Android中ListView的使用(不用ListActivity)
- Android关于ListView的总结--使用ListActivity
- Android关于ListView的总结--使用ListActivity
- Android中Activity中使用ListView与ListActivity中使用ListView的区别与联系
- Android ListActivity使用
- Android ListActivity使用
- 第四章--android核心组件之Activity与ListActivity中使用ListView的区别
- android的listactivity实例
- ListActivity的使用
- ListActivity的使用介绍
- 通过java反射改变listview fastscroll图片
- STL运用的C++技术(7)——代码整合
- sed的使用
- spring job
- 今天的实训
- android-ListActivity与HashMap的简单使用
- The APR based Apache Tomcat Native library which allows optimal performance in production environmen
- 超图hypergraph
- find 的命令是强大, 要会用才好
- The APR based Apache Tomcat Native library which allows optimal performance in production environme
- C# 中 finally 的用法
- 线程同步 线程死锁
- if_changed_rule/cc_o_c/any-prereq/arg-check
- 关于WindowsXP