用ListView和Adapter就可以实现了啊
解决方案 »
- GC_FOR_MALLOC freed 9803 objects 求解
- 创建android项目时的错误?
- 求助一个很菜鸟的问题
- 创建AudioRecord时 报Unknown PCM AndroidRecord 是什么原因?
- 关于源码中开机logo上闪动的光标
- 关于同一个activity,不同显示的问题!~!!寻求解决方案。。。
- 请问如何获取系统语言列表
- adt卸载问题
- 关于logcat 不停报同一条信息的问题
- netd,vold都通过tcp向framework提供服务,sf却通过binder
- Windows CE 6.5与Android区别?各有什么优缺点?
- 用来静态显示的XML文件中,可否加入事件处理代码???
我曾经做的一个
listview1.xml的代码
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="用户信息"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/users"
/>
</LinearLayout>
public class LView1 extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview1);
ListView listView = (ListView)findViewById(R.id.users);
ArrayList<HashMap<String,Object>> users
= new ArrayList<HashMap<String,Object>>();
for(int i=0;i<10;i++){
HashMap<String,Object> user = new HashMap<String,Object>();
user.put("img",R.drawable.icon );
user.put("name", "用户->"+i);
user.put("age", 20+i);
users.add(user);
}
SimpleAdapter adapter =
new SimpleAdapter(this,users,R.layout.user,
new String[]{"img","name","age"},
new int[]{R.id.img,R.id.name,R.id.age});
listView.setAdapter(adapter);
}
android有专门的api实现,即Preferences(PreferenceActivity)
android 示例代码就有几个例子,楼主自己可以查看下,App目录下的Preferences。
结贴~