开发者

Problem with custom views in Gallery (false focus received by component)

I'm having problem figuring out an issue with the Gallery component. I'm using a simple gallery with a custom Base Adapter. In the getView method, the view representing a gallery item is inflated:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            View promo = inflater.inflate(R.layout.view_promo, null);
            ImageView promoBackground = (ImageView)promo.fin开发者_Python百科dViewById(R.id.promo_background);
            promoBackground.setBackgroundResource(promoResources[position]);
            convertView = promo;
        }
        return convertView;
    }

The inflated view also has two simple button with a selector set as background. The problem is that when the gallery item is clicked/touched, the two buttons appear to receive focus, and the selector changes the background of the two buttons (even if the touch not occurs right over them). I've tried disabling both focus and click on all views that could receive the event, but no luck yet.

Any idea is welcomed! Thanks


I just encountered this same issue, and found a solution here:

Gallery/AdapterView Child Drawable State

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜