Skip to content Skip to sidebar Skip to footer

How Can A Button Get The Focus?

There are quite a few posts touching this topic. I thought I should ask this simple question hoping to clarify this. I am unable to achieve setting the focus on a button. I know

Solution 1:

update your code:

        Button button = (Button)findViewById(R.id.button1);
        button.setFocusable(true);
        button.setFocusableInTouchMode(true);///add this line
        button.requestFocus();
        button.setText("Debug"); 

Post a Comment for "How Can A Button Get The Focus?"