开发者

how to disable an item in my ListView

I have a ListView set in my AlertDialog in Android and i'm trying to add separators as heading titles to help organize the information. I figured out how to display them... but they are s开发者_StackOverflow社区till selectable by the user which isn't good.

Is there a way to disable an item to be selectable in an Android ListView? I found an method isEnabled(int position) to see if an item is enabled or not but none to see if its disabled.


Just Now i have implemented it

ListView list=new ListView(this);
list.getChildAt(0).setEnabled(false);


override this in ur code to disable the focus.

         @Override
         public boolean isEnabled(int position) {
            return false;
           }


I've found a lot of comments saying that

setEnabled(false)
setClickable(false)
setFocusable(false)

would work, but the answer is NO

The only workaround for this approach is doing:

view = inflater.inflate(R.layout.row_storage_divider, parent, false);
view.setOnClickListener(null);


setClickable(False) works fine for me . try it once . in case problem will be persist i will share my custom adapter with you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜