0

.setEnabled() 似乎只工作一次是有原因的吗?我希望根据内容在活动生命周期中多次打开和关闭它。我已经尝试将它包装在 switch 语句中。

        GAME_STATE_INPLAY = true;       
        if (GAME_STATE_INPLAY = true) {
            explainButton.setEnabled(false);
        }
    ....
        if (c.getString(7).toString().length() > 0) {
                explainButton.setEnabled(true);
        }
4

1 回答 1

0

尝试再次通过 id 获取 btn:

   if (GAME_STATE_INPLAY = true) {
        Button explainButton =(Button) findViewById(R.id.button);
        explainButton.setEnabled(false);
    }

    if (c.getString(7).toString().length() > 0) {
            Button explainButton =(Button) findViewById(R.id.button);
            explainButton.setEnabled(true);
    }
于 2012-10-04T08:16:38.973 回答