A手机是Android4.1.2,B手机是Android4.4.4,两部手机加载Gallery异常

logohoo 2015-05-20 12:36:17


我用Android studio开发一个app,
用两把手机调试,都是华为,A手机是Android4.1.2,B手机是Android4.4.4,
app上加载一个Gallery滚动栏,栏上有很多文字选项。
实机A和B调试,为什么
A手机可以正常显示Gallery滚动栏,而A手机出现栏是空白的,什么都没有显示?
为什么,请高手指教。
...全文
216 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
logohoo 2015-05-20
  • 打赏
  • 举报
回复
奇怪得要死,一定要等activity出现后,在上面搞个按钮,按钮事件是:gr_heads.bringToFront();才能显示出来啊,否则不能显示, 求帮助,这是为什么啊?难道gr_heads默认是在其父容器的底下面吗?怎样让它初始化能在最上面啊,不用搞个按钮去gr_heads.bringToFront();它啊。 为什么A手机不用啊。
logohoo 2015-05-20
  • 打赏
  • 举报
回复
public class ImageAdapter extends BaseAdapter { private LayoutInflater inflater; private Context context; private int widthCount; private int itemWidth; private int count=0; public Bitmap[] itemBitmaps=null;//每item的视图显示图片; public int selectPosition=0; public void recycleBitmaps() { if(itemBitmaps!=null){CBitmap.recycle(itemBitmaps);} } public void reloadBitmaps(Bitmap[] bitmaps) { recycleBitmaps(); itemBitmaps=CBitmap.createScaledBitmaps(bitmaps,CSetup.time);//在退出时候要recycle count=itemBitmaps.length; } public ImageAdapter(Context ct, Bitmap[] bitmaps,int n) { context = ct; widthCount=n; DisplayMetrics dm = context.getResources().getDisplayMetrics(); itemWidth=(int)dm.widthPixels/(widthCount+1); inflater = LayoutInflater.from(context); reloadBitmaps(bitmaps); } public int getCount() { return count; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { if(convertView!=null) { return convertView; } else { View layoutView=inflater.inflate(R.layout.gallery_item_image, null);//从layout的gallery_item_image.xml获取一个实例化的布局视图; //设置Gallery的一个item view的大小; layoutView.setLayoutParams(new Gallery.LayoutParams(itemWidth,itemWidth));//注意参数是layoutView的父容器; ImageView iv=(ImageView)layoutView.findViewById(R.id.imageview_item);//从布局视图中获取已实例化的一个子view; if(position!=selectPosition) { iv.setBackgroundResource(R.drawable.bg_gallery_item_nothing); } else { iv.setBackgroundResource(R.drawable.bg_gallery_item_selected); } iv.setImageBitmap(itemBitmaps[position]); return iv; } } } <LinearLayout android:id="@+id/layout_heads" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/px_1" android:orientation="vertical" > <com.logohoo.manstore.app.Gallery android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/gallery_heads" android:background="@color/cl_yellow" > </com.logohoo.manstore.app.Gallery> </LinearLayout>
logohoo 2015-05-20
  • 打赏
  • 举报
回复
就是app的activity显示后,Gallery可以显示出背景,但是里面的视图图片看不到,一刷新Gallery后,连Gallery的背景都没有了,只有Gallery的父容器的背景出现。问Gallery跑去哪里了?
yexianghu 2015-05-20
  • 打赏
  • 举报
回复
多给点信息,比如显示的截图,layout是怎么写的,theme用的是哪一个
logohoo 2015-05-20
  • 打赏
  • 举报
回复
奇怪的是,只有在B手机的 BaseAdapter的 public View getView(int position, View convertView, ViewGroup parent) 上断点,然后一步一步调试,gallery上的view就能显示出图片,但是向左滚动一下,就没有了。
logohoo 2015-05-20
  • 打赏
  • 举报
回复
继续顶上去,版主帮帮忙啊,我发的帖子,一次有效回复都没有啊?晕,救命。
yexianghu 2015-05-20
  • 打赏
  • 举报
回复
1. 刷新Gallery 的操作是什么? 2. Gallery在layout里面的高度为什么要设置成 wrap_content ? 难道这个Gallery不是全屏的吗?

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧