设为首页 加入收藏

TOP

Android基础教程:使用ListView显示信息
2014-11-24 12:56:03 来源: 作者: 【 】 浏览:0
Tags:Android 基础 教程 使用 ListView 显示 信息

以显示注册信息为例:


一、创建带有ListView的Activity要继承ListActivity


this.setContentView(R.layout.user);


二、ListActivity的布局文件user.xml



andoid:scrollbars="vertical"


android:drawSelectorOnTop="false">


三、使用intent获得用户保存的信息


Intent intent = getIntent();


String username = intent.getStringExtra("username");




四 、创建要显示的list内容


HashMap map1 = new HashMap();


..


map1.put("user_key","姓名");


map 1.put("user_value",username);


...


//对数组进行拆分


String hob = "";


for(String h:hobby){


hob += h=" ";


}


List> list = new ArrayList>();


list.add(map1);


...


五、设置适配器


设置list.xml布局文件;


指定list控件


SimpleAdapter adapter = new SimpleAdapter(this,list,R.layout.list,


new String[]{"user_key","user_value"},


new int[]{R.id.userkey,R.id.uservlaue}


);


setListAdapter(adapter);


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android里面所应用到的注册权限 下一篇使用Qt和Interpreter设计模式开发..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·哈希表 - 菜鸟教程 (2025-12-24 20:18:55)
·MySQL存储引擎InnoDB (2025-12-24 20:18:53)
·索引堆及其优化 - 菜 (2025-12-24 20:18:50)
·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)