开发者

Disableing Android listview

开发者 https://www.devze.com 2023-02-20 11:05 出处:网络
I have a view with a listview and several other views including a button and a few e开发者_如何学JAVAdittexts. I want the listview to be scrollable but not clickable after i press the button.

I have a view with a listview and several other views including a button and a few e开发者_如何学JAVAdittexts. I want the listview to be scrollable but not clickable after i press the button. Any suggestions?


I would add a field, something like:

private boolean clicked = false;

I would then go into the onClick method and add something like

    if(!clicked){
//Do Stuff on the click
    clicked = true;
}
else if(clicked){
//do nothing
}

then to accept a click again you would first have to set clicked to false again, and then continue to accept clicks.


You need disable the clicklisteners for the listview by calling setOnClickListener to null , @Aaron Decker's solution is good too :-)

0

精彩评论

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

关注公众号