When the button is pressed, is this status lost when opening the options menu?
I created a sample activity to clarify this:
public class increases main activity activity {@ Override Protected Zero at Crete (Bundle Saved InstantStat) { Super.onCreate (savedInstanceState); SetContentView (R.layout.activity_main); Button BTN = (button) Find VVBIID (R.B. button 1); Btn.setPressed (right); // set state} @ override public boolean on crat option menu (menu menu) {getMenuInflater (). Flood (R. menu menu, menu); Back true; } @ Override Public Boolean On Option Itam (Menu Item Item) {int id = item.getItemId (); If (id == R.id.action_settings) is true back; Return super.onOptionsItemSelected (item); }}
We have set the pressed state the button in our view. When you run the project and then open the options menu, the pressed state goes. It seems that the button has removed its position.
What is the solution / solution to keep the button without making the entire activity again? Probably the implementation of a button is not for this behavior and need to use the toggle button?
increases the main activity activity of the public class (button BTN; @ Override protected zero Create (Bundle Saved InstantState) {Super.New (Saved Instantstate); setContentView (R.layout.activity_main); btn; = Find VVBID (R.B.ton1); btn.setPressed (true); // set state} @ override public boolean on cret option menu (menu menu) {getMenuInflater (). Flowers (R. menu menu, menu); // here you Set your status ... Set BTN // state ... true back;} @ override public boolean on option etam selected (menu item) {int id = item.getItemId (); if (id == R.id.action_settings) return true; return super.onOptionsItemSelected (item);}}
No comments:
Post a Comment