首页 > 系统 > Android > 正文

Android实现取消GridView中Item选中时默认的背景色

2020-04-11 10:48:00
字体:
来源:转载
供稿:网友

本文实例讲述了Android实现取消GridView中Item选中时默认的背景色。分享给大家供大家参考,具体如下:

1.  取消GridView中Item选中时默认的背景色,当使用GridView时候点击item项时候,会有一个android默认的背景色,取消它的方法是:

game_gridview.setSelector(new ColorDrawable(Color.TRANSPARENT));//取消GridView中Item选中时默认的背景色

2.  GridView第一个item不显示的问题

View view = null;if(convertView != null){view = convertView;}else {  view = getLayoutInflater().inflate(R.layout.game_layout_item, null);  view.setLayoutParams(new GridView.LayoutParams(game_gridview.getWidth() / 4, game_gridview.getHeight() / 4));}ImageView image_head = (ImageView) view.findViewById(R.id.image_head);return view;

有代码可以看出是view.setLayoutParams放错了位置,应该放到if  else 外面。

更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android Service组件使用技巧总结》、《Android基本组件用法总结》及《Android控件用法总结

希望本文所述对大家Android程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表