开发者

Android - Can't Click on Button

开发者 https://www.devze.com 2023-02-16 09:00 出处:网络
I have a button that is declared \"gone\" in the XML file: android:visibility=\"gone\" Therefore, by default the button is hidden.The button will become visible depending on another condition in t

I have a button that is declared "gone" in the XML file:

android:visibility="gone" 

Therefore, by default the button is hidden. The button will become visible depending on another condition in the .java by the following line.:

smsexplain.setVisibility(0);

I have set up a proper onClickListener for the button v开发者_Python百科ia:

Button edit = (Button) findViewById(R.id.edithookup_req);
        edit.setVisibility(0);
        edit.setOnClickListener(onEdit);

The problem arises in runtime. The button shows up like it is suppose to; however, the button cannot be touched. The only way to set off the onClickListener is to use the D-pad or scroll-ball on the physical phone.

Any ideas?


You shouldn't use setVisibility() with a 0.

Try using the correct variable from the View class. For example: View.VISIBLE.

0

精彩评论

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

关注公众号