- 浏览: 169755 次
- 性别:
- 来自: 深圳
最新评论
-
solomon0104:
sraining 写道瞎扯,,自己试验一下,垃圾
Android 注册广播的两种方式区别 -
org_zhanghua:
为什么我这边上传成功后,提示下载json请指导一下:http: ...
spring mvc ajaxfileupload上传文件 -
zhongzixing:
你好,由于公司网络需要设置代理,并且需要用户和密码才能上网。我 ...
android SDK安装出现Failed to fetch URL http://dl-ssl.google.com/android/repository/a -
kuanye345:
博主 给个demo 啊
使用百度地图画轨迹 -
dou_yer:
有没有源码可以提供啊。。谢谢。
带进度条的通知栏
listview显示数据,类似HTML那样的table显示。显示不足的时候,横屏可以拖拉。
Activity 包括数据
package com.jdjw.test; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.widget.ListView; import com.jdjw.test.TableAdapter.TableCell; import com.jdjw.test.TableAdapter.TableRow; public class TestGridViewTableActivity extends Activity { private ListView lvSaleNum; private List<TableRow> table; private Context mContext; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.test_gridview_table); lvSaleNum = (ListView)findViewById(R.id.lv_salesNum); mContext = this; data(); } private void data(){ salesNum s1 = new salesNum("星期一",50,60,R.drawable.a0,60,80,R.drawable.a1); salesNum s2 = new salesNum("星期二",50,60,R.drawable.a0,10,80,R.drawable.a0); salesNum s3 = new salesNum("星期三",120,30,R.drawable.a1,30,80,R.drawable.a0); salesNum s4 = new salesNum("星期四",50,50,R.drawable.a0,80,80,R.drawable.a1); salesNum s5 = new salesNum("星期五",10,20,R.drawable.a0,62,60,R.drawable.a0); salesNum s6 = new salesNum("星期六",80,10,R.drawable.a1,90,80,R.drawable.a0); salesNum s7 = new salesNum("星期日",50,90,R.drawable.a0,50,30,R.drawable.a0); List<salesNum> data = new ArrayList<salesNum>(); data.add(s1); data.add(s2); data.add(s3); data.add(s4); data.add(s5); data.add(s6); data.add(s7); int width = getWindowManager().getDefaultDisplay().getWidth()/7; table = new ArrayList<TableRow>(); int height=30;//LayoutParams.FILL_PARENT; TableCell[] titleCells = new TableCell[7]; List<TableCell> titleList = new ArrayList<TableCell>(); TableCell title1 = new TableCell("时间",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title1); TableCell title2 = new TableCell("上月条码数",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title2); TableCell title3 = new TableCell("本月条码数",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title3); TableCell title4 = new TableCell("条码趋势",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title4); TableCell title5 = new TableCell("上月销售金额",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title5); TableCell title6 = new TableCell("本月销售金额",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title6); TableCell title7 = new TableCell("销售金额趋势",width + 8 ,height, TableCell.TEXT);//第一格 titleList.add(title7); table.add(new TableRow(titleList.toArray(titleCells))); for(int i=0;i<data.size();i++){ salesNum sales = data.get(i); TableCell[] cells = new TableCell[7]; List<TableCell> cellsList = new ArrayList<TableCell>(); TableCell cell1 = new TableCell(sales.getWeek(),width + 8 ,height, TableCell.TEXT);//第1格 cellsList.add(cell1); TableCell cell2 = new TableCell(sales.getBackMonthNum(),width + 8 ,height, TableCell.TEXT);//第2格 cellsList.add(cell2); TableCell cell3 = new TableCell(sales.getNextMonthNum(),width + 8 ,height, TableCell.TEXT);//第3格 cellsList.add(cell3); TableCell cell4 = new TableCell(sales.getNumImage(),width + 8 ,height, TableCell.IMAGE);//第4格 cellsList.add(cell4); TableCell cell5 = new TableCell(sales.getBackMonthMomey(),width + 8,height, TableCell.TEXT); cellsList.add(cell5); TableCell cell6 = new TableCell(sales.getNextMonthMomey(),width + 8 ,height, TableCell.TEXT); cellsList.add(cell6); TableCell cell7 = new TableCell(sales.getMomeyImage(),width + 8 ,height, TableCell.IMAGE); cellsList.add(cell7); table.add(new TableRow(cellsList.toArray(cells))); } //设置适配器 TableAdapter adapter = new TableAdapter(mContext,table); lvSaleNum.setAdapter(adapter); } class salesNum{ private String week; private int backMonthNum; private int nextMonthNum; private int numImage; private int backMonthMomey; private int nextMonthMomey; private int momeyImage; public salesNum(){} public salesNum(String week,int backMonthNum,int nextMonthNum,int numImage,int backMonthMomey,int nextMonthMomey,int momeyImage){ this.week = week; this.backMonthNum = backMonthNum; this.nextMonthNum = nextMonthNum; this.numImage = numImage; this.backMonthMomey = backMonthMomey; this.nextMonthMomey = nextMonthMomey; this.momeyImage = momeyImage; } public String getWeek() { return week; } public void setWeek(String week) { this.week = week; } public int getBackMonthNum() { return backMonthNum; } public void setBackMonthNum(int backMonthNum) { this.backMonthNum = backMonthNum; } public int getNextMonthNum() { return nextMonthNum; } public void setNextMonthNum(int nextMonthNum) { this.nextMonthNum = nextMonthNum; } public int getNumImage() { return numImage; } public void setNumImage(int numImage) { this.numImage = numImage; } public int getBackMonthMomey() { return backMonthMomey; } public void setBackMonthMomey(int backMonthMomey) { this.backMonthMomey = backMonthMomey; } public int getNextMonthMomey() { return nextMonthMomey; } public void setNextMonthMomey(int nextMonthMomey) { this.nextMonthMomey = nextMonthMomey; } public int getMomeyImage() { return momeyImage; } public void setMomeyImage(int momeyImage) { this.momeyImage = momeyImage; } } } 适配器 package com.jdjw.test; import java.util.List; import android.content.Context; import android.graphics.Color; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; /** * ListView自适应实现Table的类TableAdapter.java代码如下: * * PS:TableCell是格单元的类,TableRow是表格行的类,TableRowView是实现表格行的组件。 实现步骤:TableCell --> * TableRow(TableRowView)-->ListView * * */ public class TableAdapter extends BaseAdapter { private Context context; private List<TableRow> table; // 7行7列 public TableAdapter(Context context, List<TableRow> table) { this.context = context; this.table = table; } @Override public int getCount() { return table.size(); } @Override public long getItemId(int position) { return position; } public TableRow getItem(int position) { return table.get(position); } int i = 0; public View getView(int position, View convertView, ViewGroup parent) { TableRow tableRow = null; tableRow = table.get(position);// 得到行 TableRowView view; if (convertView == null) { view = new TableRowView(this.context, tableRow); convertView = view; } return convertView; } /** * TableRowView 实现表格行的样式 * * @author hellogv */ class TableRowView extends LinearLayout { public TableRowView(Context context, TableRow tableRow) { super(context); this.setOrientation(LinearLayout.HORIZONTAL); for (int i = 0; i < tableRow.getSize(); i++) {// 逐个格单元添加到行 TableCell tableCell = tableRow.getCellValue(i); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( tableCell.width, tableCell.height);// 按照格单元指定的大小设置空间 layoutParams.setMargins(0, 0, 1, 1);// 预留空隙制造边框 if (tableCell.type == TableCell.TEXT) {// 如果格单元是文本内容 TextView textCell = new TextView(context); textCell.setLines(1); textCell.setGravity(Gravity.CENTER); // textCell.setBackgroundColor(Color.BLACK);//背景黑色 textCell.setText(String.valueOf(tableCell.value)); addView(textCell, layoutParams); } else if (tableCell.type == TableCell.IMAGE) {// 如果格单元是图像内容 ImageView imgCell = new ImageView(context); // imgCell.setBackgroundColor(Color.BLACK);//背景黑色 imgCell.setImageResource((Integer) tableCell.value); addView(imgCell, layoutParams); } } // this.setBackgroundColor(Color.WHITE);//背景白色,利用空隙来实现边框 } } /** * TableRow 实现表格的行 * * @author hellogv */ static public class TableRow { private TableCell[] cell; public TableRow(TableCell[] cell) { this.cell = cell; } public int getSize() { return cell.length; } public TableCell getCellValue(int index) { if (index >= cell.length) return null; return cell[index]; } } /** * TableCell 实现表格的格单元 * * @author hellogv */ static public class TableCell { static public final int TEXT = 0; static public final int IMAGE = 1; public Object value; public int width; public int height; private int type; public TableCell(Object value, int width, int height, int type) { this.value = value; this.width = width; this.height = height; this.type = type; } } }
xml 布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <!-- 添加横向滑动 设置fillviewport为truey意思是否将HorizontalScrollView的内容宽度拉伸以适应视口--> <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" > <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/lv_salesNum" /> </HorizontalScrollView> </LinearLayout>
发表评论
-
android viewstub
2013-08-08 14:56 2406利用ViewStub显示和隐藏布局 Vie ... -
android SDK安装出现Failed to fetch URL http://dl-ssl.google.com/android/repository/a
2013-04-21 09:26 8953早上起来弄了下环境,直接在android官方下载了个a ... -
cygwin+android ndk 编译FBReaderJ 开源项目
2012-09-06 11:00 2761不知道为什么老外的开源项目比较麻烦 我在http://www ... -
android 发送邮件
2012-08-14 17:34 2889android发邮件;提供了两种方式,只带的gmail发送;跟 ... -
java基本概念
2012-06-27 17:26 1191【形参与实参】 形参 ... -
Android 注册广播的两种方式区别
2012-03-22 14:26 139581.常驻型广播 常驻型广播,当你的应用程序关闭了,如果有 ... -
android keytool的一些使用命令
2012-02-13 11:46 2421Keytool是一个Java数据证书的管理工具 ,在打包apk ... -
带进度条的通知栏
2011-12-22 15:03 2652有时候会有些业务需要后台运行并以通知的形式,比如升级,监控什么 ... -
activityGroup 多个view无法自动弹出虚拟键盘
2011-12-01 11:41 1673使用activityGroup 中多个view中进行切换时如果 ... -
android中的短信操作
2011-10-20 15:34 1872在android读取短信并进行相应的管理时,可以进行短信箱删除 ... -
【原创】出行通v1.0面世了。欢迎大家免费下载
2011-10-04 00:23 1101如果你还为出门坐车而发难吗?如果回家还要去火车站查询车次和价位 ... -
使用百度地图画轨迹
2011-09-16 15:59 16546百度地图画轨迹连接线。 package com.li ...
相关推荐
android 布局中网格视图 ListView的简单运用 采用的是最简单的ArrayAdapter适配器
这是一个android listview分页查询显示的demo,使用sqlite数据库,然后每次显示10条,上拉加载更多数据,studio项目
Android ListView数据分类显示
本文实例为大家分享了Android ListView实现图文列表显示的具体代码,供大家参考,具体内容如下 目标效果: ListView如果内容过多,可以滑动屏幕来显示,并且点击某一行可使用吐司方法弹出对应的水果名字。 1....
NULL 博文链接:https://staroflife.iteye.com/blog/1749672
android listView 改变选中行的 字体颜色和 图片
Android ListView卡片效果,源码下载。
android Listview 分栏显示,仿百度下载模块,一个ListView中有两种不同的布局,当滑动到第二种布局的时候自动切换title中显示的内容
实现了 Android listView 分页功能,代码可以运行,功能完善。
Android ListView边框圆角美化,可以用来仿iphone的个别界面。相当有用。美观。
Android listview实现自动自动换行!
Android ListView 实例源码
Android listview 下拉 刷新
android ListView简单用法
android listview 固定表头,固定前几列
Android完美解决listview中多个edittext显示混乱问题,内含源码及apk文件
Android listview viewpager 滑动 跳动 冲突解决 ListView中嵌套ViewPage有或者滑动手势冲突解决 blog 地址 : http://blog.csdn.net/aaawqqq/article/details/43824631
android1.6 + eclipse
Android ListView页面加载数据显示更多
使用实现ListView实现微信好友列表 android ListView 微信 好友列表 自定义ImageView 自定义ListView