设为首页 加入收藏

TOP

Android基础教程:使用ListView显示信息
2014-11-24 12:56:03 来源: 作者: 【 】 浏览:1
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设计模式开发..

评论

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

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)