SimpleAdapter添加了元素后没有内容显示
2013-09-11 18:46
218 查看
布局文件
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 定义一个List -->
<ListView
android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!-- 定义ImageView作为List的一部分 -->
<ImageView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dp" />
<!-- 定义TextView作为List的一部分 -->
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:gravity="center_vertical"
android:paddingLeft="10dp" />
</LinearLayout>
设置主布局
super.onCreate(savedInstanceState);
setContentView(R.layout.simpleadapter_listview_main);
在创建SimpleAdapter 时,item要有自己的layout
SimpleAdapter simpleAdapter = new SimpleAdapter(this,
listItems,
R.layout.listview_main,
new String[] {"header", "personName"},
new int[] {R.id.header, R.id.name});
imageview和textview不是写在主layout里,而是写在自己的item layout中,所以上面的布局文件应该写两个
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 定义一个List -->
<ListView
android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!-- 定义ImageView作为List的一部分 -->
<ImageView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dp" />
<!-- 定义TextView作为List的一部分 -->
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:gravity="center_vertical"
android:paddingLeft="10dp" />
</LinearLayout>
设置主布局
super.onCreate(savedInstanceState);
setContentView(R.layout.simpleadapter_listview_main);
在创建SimpleAdapter 时,item要有自己的layout
SimpleAdapter simpleAdapter = new SimpleAdapter(this,
listItems,
R.layout.listview_main,
new String[] {"header", "personName"},
new int[] {R.id.header, R.id.name});
imageview和textview不是写在主layout里,而是写在自己的item layout中,所以上面的布局文件应该写两个
相关文章推荐
- 动态添加Jquery元素后在UI中没有显示
- 动态添加Jquery元素后在UI中没有显示
- 动态添加Jquery元素后在UI中没有显示
- [已解决]AutoCompleteTextView 不显示匹配的内容,因为将空的内容添加进去了
- 2015.7.23 第十二课 课程重点(jq元素:获取、添加、删除、设置、绑定、显示隐藏、回调、动画)
- 帝国cms内容页某个字段没有填写就不显示的解决方法
- Hexo博客首页自动添加Read More标记-不在首页显示全部文章全部内容
- foot元素内容未满或超过一页都底部显示
- linux mint 向“显示(display)”面板添加没有提供的分辨率选项,使虚拟机中的linux mint可以全屏显示
- 编写一个简易的留言薄,实现添加留言和显示留言内容等功能
- JQeury显示内容没有边距怎么办?
- 列表之间内容相互移动,列表添加元素
- 页面内容添加新的显示或者显示隐藏的内容,滚动条滚动到最低端,显示出新内容
- android学习记录(三)百度地图错误---只有一个电话显示帧,没有地图内容。
- 网页动态添加的内容,没有触发事件
- WebView android 内容没有全部显示
- 行的内容变换到列显示,并且添加行求和,列求和
- 文件下载,在ie和谷歌中是好的,在火狐中名称显示不全,没有后缀类型显示application/octet-stream,或者内容乱码
- 添加的SWT控件没有显示出来
- 解决JQeury显示内容没有边距内容紧挨着浏览器边线