I have 4 buttons in my layout, now when I press any button, after the click event, the button should be high, indicating that it was last pressed.
To create such a thing, I tried the following:
the code:
btn1.setOnClickListener(new button_click_listener()); btn2.setOnClickListener(new button_click_listener()); class button_click_listener implements Button.OnClickListener { @Override public void onClick(View v) { if(v==btn1) { btn1.requestFocus(); } if(v==btn2) { btn2.requestFocus(); } ....... } }
XML layout:
<Button android:text="Click 1" android:id="@+id/btnClick1" android:layout_width="70dp" android:layout_height="wrap_content" style="@android:style/Widget.Button.Small" android:padding="10dp" android:focusableInTouchMode="true"> </Button>
How to show the click on the button that was last pressed? Please show me the way and give advice.
Update:
If I set android:focusable="true" , then the button will be highlighted and focused, but at the same time I need to double-click the button to execute the actual click event.
android button
Paresh mayani
source share