如何在android上获得imageButton的可点击状态

时间:2015-01-09 07:50:14

标签: java android eclipse imagebutton clickable

btnCall.setClickable(false);    

我使用此代码进行设置,但我想得到它。

谁知道答案请建议我?

2 个答案:

答案 0 :(得分:1)

以下是ImageButton的可点击状态:

    ImageButton myButton = (ImageButton) findViewById(R.id.button1);
    myButton.setClickable(false);

    // if clickable is false
    if (myButton.isClickable() == false) {
        Log.i("MyButton", "Clickable is false");
        // do your things here
        ...
    }

    // if clickable is true
    if (myButton.isClickable() == true) {
        Log.i("MyButton", "Clickable is true");
        // do your things here
        ...
    }

答案 1 :(得分:0)

这是针对Android的,因为你在标题中已经提到过了!

如果您想知道ImageButton是否可点击,请使用..

boolean status = btnCall.isClickable(); // will return true if its clickable, false otherwise