社区
Android
帖子详情
android listView 第一列为什么不能居中
ghostgoodbye
2012-03-13 05:13:42
在我的listView中除了第一行是居中的,其余的怎么不能居中啊 谢谢 拉
...全文
523
2
打赏
收藏
android listView 第一列为什么不能居中
在我的listView中除了第一行是居中的,其余的怎么不能居中啊 谢谢 拉
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ghostgoodbye
2012-03-13
打赏
举报
回复
我的是创建了一个对象 具体代码是:
BaseAdapter ba_detail=new BaseAdapter()//新建适配器
{
@Override
public int getCount()
{
return 5;//得到列表的长度
}
@Override
public Object getItem(int arg0){return null;}
@Override
public long getItemId(int arg0){return 0;}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2)//为每一项添加内容
{
LinearLayout ll_detail=new LinearLayout(sprinkler_detail_infomation.this);
ll_detail.setOrientation(LinearLayout.HORIZONTAL); //设置朝向
ll_detail.setPadding(5,5,5,5);
ll_detail.setGravity(Gravity.CENTER);//四周留白
TextView tv1=new TextView(sprinkler_detail_infomation.this);
tv1.setWidth(50);
tv1.setHeight(50);
tv1.setGravity(Gravity.CENTER);
tv1.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50]);
tv1.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv1);
TextView tv2=new TextView(sprinkler_detail_infomation.this);
tv2.setWidth(72);
tv2.setHeight(50);
tv2.setGravity(Gravity.CENTER);
tv2.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+1]);
tv2.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv2);
TextView tv3=new TextView(sprinkler_detail_infomation.this);
tv3.setWidth(123);
tv3.setHeight(50);
tv3.setGravity(Gravity.CENTER);
tv3.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+2]);
tv3.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv3);
TextView tv4=new TextView(sprinkler_detail_infomation.this);
tv4.setWidth(85);
tv4.setHeight(50);
tv4.setGravity(Gravity.CENTER);
tv4.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+3]);
tv4.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv4);
TextView tv5=new TextView(sprinkler_detail_infomation.this);
tv5.setWidth(55);
tv5.setHeight(50);
tv5.setGravity(Gravity.CENTER);
tv5.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+4]);
tv5.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv5);
TextView tv6=new TextView(sprinkler_detail_infomation.this);
tv6.setWidth(85);
tv6.setHeight(50);
tv6.setGravity(Gravity.CENTER);
tv6.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+5]);
tv6.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv6);
TextView tv7=new TextView(sprinkler_detail_infomation.this);
tv7.setWidth(85);
tv7.setHeight(50);
tv7.setGravity(Gravity.CENTER);
tv7.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+6]);
tv7.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv7);
TextView tv8=new TextView(sprinkler_detail_infomation.this);
tv8.setWidth(85);
tv8.setHeight(50);
tv8.setGravity(Gravity.CENTER);
tv8.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+7]);
tv8.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv8);
TextView tv9=new TextView(sprinkler_detail_infomation.this);
tv9.setWidth(85);
tv9.setHeight(50);
tv9.setGravity(Gravity.CENTER);
tv9.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+8]);
tv9.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv9);
TextView tv10=new TextView(sprinkler_detail_infomation.this);
tv10.setWidth(85);
tv10.setHeight(50);
tv10.setGravity(Gravity.CENTER);
tv10.setText(gNameAndgDetail[arg0*10+(modify_number-1)*50+9]);
tv10.setTextColor(getResources().getColor(R.color.text_color));
ll_detail.addView(tv10);
return ll_detail;//将此LinearLayout返回
}
};
pby_bob
2012-03-13
打赏
举报
回复
楼主这个问题提的太初略了,能不能再详细点,是继承了什么adapter?
多重ScrollView、HorizontalScrollView、
ListView
嵌套的死磕!
本来计划第一篇自己的博客是计划从CustomView开始的,由于个人的原因呢。一直搁置了两个月下来,这段时间发生的事情,过程不算顺利,但是收获不可谓不大!本例呢是根据公司最近的需求做的demo,原创度不高,更多的是...
Android
Java 网络 OS等笔试题 -- 全
1、
Android
的四大组件是哪些,它们的作用? 3 2、请介绍下
Android
中常用的五种布局。 3 3、
android
中的动画有哪几类,它们的特点和区别是什么 3 4、
android
中有哪几种解析xml的类?官方推荐哪种?以及它们的...
android
Java 笔试考题
前19题为常考题目!!(版本号:201108141031...
android
中的动画有哪几类,它们的特点和区别是什么 3 4、
android
中有哪几种解析xml的类?官方推荐哪种?以及它们的原理和区别。 3 5、
ListView
的优化方案 4 6、 请介
Android
之布局详解
key Value
android
:layout_centerHrizontal 水平
居中
android
:layout_centerVertical 垂直
居中
android
:layout_centerInparent 相对于父元素完全
居中
android
:layout_alignParentBottom 贴紧父元素的下边缘
android
:...
Android
个人每天总结.doc(1)
1.
Android
个人每天总结.doc 2.
Android
基础总结.doc 这两个文件 篇幅太长, 有100多页。 直接放在这里很不合适。 这里最多 一个篇幅, 最好是不超过。10页。 ====
Android
基础 day01 Ø Eclipse中一...
Android
80,362
社区成员
91,291
社区内容
发帖
与我相关
我的任务
Android
移动平台 Android
复制链接
扫一扫
分享
社区描述
移动平台 Android
android
android-studio
androidx
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章