开发者

Can't select specific objects in custom list - Android

I'm building an Android program that includes a custom list view. The list itself works fine, and each object(row) contains one text view and one image.

I want that a different action will be carried out when the user is pressing each of the widgets.

What actually happens is that when the user is pressing t开发者_运维百科he row, the whole row is being selected, and I can't figure out what he chose. I've looked through a lot of guides, and couldn't find a solution.

Thanks!


What so adapter you are using to set the listview must have a getView Method. In the getView method all the view are set to return a single cell view. set the onclick listener of elements in the getView method individualy for each of your text view and image to set any flag or do what ever you want to do. .

check this link also for listview

Change ListView background - strange behaviour

in this within the getView method do something like

  holder.officesTitle.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                        do here what you want to do on item specific text click  

        }
    });

Hope this help and you can modify it according to your need

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜