hi all how to implement code for Radio button when i take the radio group i take only two radio buttons from that radio button when i select the second radio button after changing the orientation second radio button is disable (i mean when i select the second radio button in the portrait mode if i change to landscape mode radio button first one is enable and second one disable but my intention is second have to be enable )how to solve this problem so plz help me over come from this problem
Simply add android:configChanges="orientation" in AndroidManifest.xml of that Activity.
When changing orientation on Android, the activity is reinitiated, i.e. it is destroyed and then restarted. What you need to do is to save your current state in the OnDestroy method and read it in the OnCreate method.
Read more on the android development webpage on activity lifecycles
Related
I would like to create activity in which it would be explained how the app is supposed to be used. On a click on a button, I would like an Activity to be opened which has next and previous buttons on the bottom. So the first screen after the click on a button would show the first instruction and you can press next to see the next instruction which opens a new screen. After going through all the instructions, I would like a Finish button to return back to the main activity.
My question is can this be made in a single activity or is it actually more activities that differ only by the text and pictures they contain?
Yes it can be done in only one activity(actually 2 if you include the main activity).
What you can do is have multiple TextViews, and when the next button is pressed, you can toggle that 1st instruction's visibility
. And so on for the next instructions. The Next/Previous buttons should determine what Textview is currently visible, so they can keep track what Textview to show next. Use switch statement
I want when a button is pressed in my activity, for the click not to occur (such as clickEnabled being false) but I want the action that would have occurred to still happen.
For example, say I have a Dialer application:
When button "One" is pressed, the user will not see that the button was actually clicked, but the action of adding a 1 to the edittext will still occur. Thank you for your help!
I think you can make a selector as your button's background.and most important is samecolor no matter that is click , touch or idle . So through this ,you fake a no click effect.
And same time ,you can also add a click listener to this button to get the click event.
Hope that give you some suggestion.
I think you should simply use onTouchListener event for buttons instead of onclickListener
my application activity has a radiogroup. It has 2 radio button.
in the xml file, i select the radiobutton1 as default when i start the activity.
Scenario :
select radio button 2
Go to phone settings and change the language.
go back to the application activity.
the activity is created again. But the radiobutton2 is selected.
Actually when i create the activity it should keep radiobutton1 as default selection. But after changing language and coming to my activity it keeps the previous state even though onCreate() is run.
I want to make radiobutton1 selected when i recreate my activity.
Kindly let me know how it can be..where am i doing wrong.
in my onDestroy() i tried radiogroup.clearcheck()
i tried to check the id of radiobutton and then set radiobutton1.checked(true).
i have onClickListener which i use to select the radio buttons.
Somehow the state is not being cleared and i cannot make radiobutton1 as default selection when i create my activity again.
Are you sure that onCreate() is called again? Because it's likely that the activity is not destroyed and thus is not created again. If that's the case, you can move the code that selects the default radio button to onResume(), which is called every time the activity is displayed, even if it is not created.
Otherwise, you should post your code so that we can help you.
When my activity starts the button starts as below image, seems that it is selected.
button seems to be selected http://kodeinfo.com/wp-content/uploads/2014/03/post4_1.jpg
Button seems to be selected but I don't select it neither on activity nor layout.
I had checked and this is not related to focus. I tried starting the activity with requestFocus() on a button and does not have the same behavior.
Does anyone knows what is that? What is this state for the button? I don't want this behavior in my app, but I'm not being able to understand the issue in my code because I don't know what this state is.
how would you disable a button until a user click on the buttons prior to it. One of the buttons has there bio info which is set in preferences. So I can't have them continue until they read the directions and fill there bio.
Disable it in the layout file and only activate it in the activity (onCreate()/onResume()) when the needed info is filled in
In onClick() for the button you want to press first call setClickable(boolean) for the button you would like to activate.
Also, if you want the button to start as being unclickable you should set the clickable attribute in your xml to false as well
<Button
android:clickable="false"
Hope this answers your question!
Perhaps make a state button for this task? Or have a state object that controls the button