百分比布局中的与GridView
来源:互联网 发布:单词朗读软件 知乎 编辑:程序博客网 时间:2024/06/07 06:36
在百分比布局(其他布局也行)中添加列表建议使用GridView
如果用listview的话过于繁琐
public class MyNews extends Activity { private GridView gview; private List<Map<String, Object>> data_list; private SimpleAdapter sim_adapter; // 图片封装为一个数组 private int[] icon = { R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher }; private String[] iconName = { "第一个", "第二个", "第三个", "第四个", "第五个", "第六个", "第七个", "第八个", "第九个", "第十个" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bai_fen); gview = (GridView) findViewById(R.id.bai_gv); //新建List data_list = new ArrayList<Map<String, Object>>(); //获取数据 getData(); //新建适配器 String [] from ={"image","text"}; int [] to = {R.id.image,R.id.tvId}; sim_adapter = new SimpleAdapter(this, data_list, R.layout.listview_item, from, to); //配置适配器 gview.setAdapter(sim_adapter); } public List<Map<String, Object>> getData(){ //cion和iconName的长度是相同的,这里任选其一都可以 for(int i=0;i<icon.length;i++){ Map<String, Object> map = new HashMap<String, Object>(); map.put("image", icon[i]); map.put("text", iconName[i]); data_list.add(map); } return data_list; }
<?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true"> <android.support.percent.PercentFrameLayout android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="top" android:background="#ffffff" app:layout_heightPercent="26%" app:layout_widthPercent="100%"> <android.support.percent.PercentFrameLayout android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="top" android:background="#ffffff" app:layout_heightPercent="50%" app:layout_widthPercent="100%"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="2016年信和大金融员工奖励标准调整通知" android:textColor="#ff0000" android:textSize="15dp" /> <ImageView android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="left|top" android:src="@mipmap/tback" app:layout_heightPercent="100%" app:layout_widthPercent="13%" /> <ImageView android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="center|left" android:src="@mipmap/tlook" app:layout_heightPercent="50%" app:layout_widthPercent="13%" /> </android.support.percent.PercentFrameLayout> <android.support.percent.PercentFrameLayout android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="bottom" android:background="#f8f8f8" app:layout_heightPercent="50%" app:layout_widthPercent="100%"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="left|center" android:paddingLeft="25dp" android:text="专项活动" android:textColor="#000000" android:textSize="25dp" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center" android:paddingRight="25dp" android:src="@mipmap/more" /> </android.support.percent.PercentFrameLayout> </android.support.percent.PercentFrameLayout> <android.support.percent.PercentFrameLayout android:layout_width="0dp" android:layout_height="0dp" android:layout_gravity="top" android:background="#ffffff" app:layout_heightPercent="54%" app:layout_marginTopPercent="26%" app:layout_widthPercent="100%"> <GridView android:id="@+id/bai_gv" android:layout_width="wrap_content" android:layout_height="match_parent"> </GridView> </android.support.percent.PercentFrameLayout></android.support.percent.PercentFrameLayout>
0 0
- 百分比布局中的与GridView
- android中的百分比布局
- Android中的百分比布局
- Android中的百分比布局
- Android中的百分比布局
- Android百分比布局的解析与扩展
- 页面的布局的百分比与像素
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- 百分比布局
- flex与布局(基本网格布局、百分比布局、一侧固定一侧自适应、圣杯布局)
- 网页布局--网页分辨率与百分比的区别
- Android 百分比布局库(percent-support-lib) 解析与扩展
- 两种IO模式:Proactor与Reactor模式
- 如何将mltbx文件导入matlab
- 一些学习笔记,仅作本人记录之用
- 题目:输入两个链表,找出它们的第一个公共结点
- NOIP2016 暑期培训 D4
- 百分比布局中的与GridView
- java虚拟机原理浅析
- poj2752 Seek the Name, Seek the Fame
- hdu 5538 House Building(长春现场赛)
- 51nod:1049 最大子段和
- C/C++零碎集——第二集
- 148.View the Exhibit. Which statements are true regarding the USERS tablespace? (Choose all that app
- Vim编辑器精通
- 刚体变量