My application is having two activities. In first activity, I have one button and in second activity I have 3 buttons and wheel view.
If I click the button from first activity it moves to second activity and if it selects any value from wheel view,that current value should be displayed in first button.
Using stored Preferences, it works fine, then if again when I select any value from wheel view that first selected value is displayed in second button and current selected item should be displayed in first button.
Can anyone help?
here,
i am using getter and setter for store the first selected value in setter and get the value into second button, here my code
setSecondBrandValue(btnCurrentSelection.getText().toString());
PreferenceConnector.writeString(WheelActivity.this, itemKeyName,
wheelMenu1[getWheel(R.id.p1).getCurrentItem()]);
and here i set the value to second button
btnSecondSelection.setText(getSecondBrandValue());
Related
I using this library to make multi state toggleButton
https://github.com/jlhonora/multistatetogglebutton
Everything works fine now.
My issue is how can make the toggle button clicked based on a value given?
Example there are three values in toggle, A,B,and C, which is in Activity B.
I'm passing value A from Activity One to Activity Two. When it comes to Activity Two, the toggle which has value A should be clicked.
It looks like you set the chosen button by it's position. You could retrieve all the texts of the buttons, find the index of the text that matches your text, and then set the chosen button with that index.
Pseudo Code:
val dataFromActivityOne = intent.getString("blah")
multiStateToggle.setValue(multiStateToggle.texts.indexOf(dataFromActivityOne))
I have the function that display a RingTone list from User's phone as a RadioGroup inside RecyclerView
The RadioGroup's size increase dynamically as the size of user's phone
Everything work perfectly except when user select a ringtone, click save and then go back again, it doesn't show the Ringtone that has been selected
How can I get the index/id of the radio button from a dynamic RadioGroup?
on that radiobutton listener like oncheckedchangelistener get it's id and save it. After that when screen's oncreate fetch that id and set selected.
One more thing in model class set one boolean variable which define radio button checked or not.
I have Activity A that runs Activity B with a button click.
Activity B has a list view with custom rows:
some rows have a title and checkboxes.
and some rows have a title and a spinner .
each row the user either checks the preferred checkboxes or chooses from a spinner.
so far so good. my problem is , when clicking back to Activity A, how do I save all the choices?
and by save I don't mean just save his checked boxes but also get the values of his choices back to Activity A.
I don't want the choices to be saved even after I restart the app. only when the app is running .
So basically I need to :
1. get the user's choices and save their values (either from a spinner or from the checkbox)
2. save the ticked checkboxes the next time the user clicks to go to activity B
I thought about using onPause in Activity B , where I will get a reference to the listView, go through every row, see if there is a checkbox or a spinner there, and then somehow see what value is checked (if its checkboxes) and what value is selected(if its a spinner).
I don't know if it's the right approach or not, anyway I really need help here.
I use onCheckedChangeListener to return the result back to MainActivity and finish the current activity. But if user decides to use the default selected value, he'd like to re-click the radiobutton to save result. How can I do that?
Thanks
Edit:
In short, how do I know if a user selects an already selected radiobutton?
If user selects the selected value then nothing changes and this method won't get called but you can check whenever you want that which radio button in a radio group is selected it should work.
If you want to check whether user has selected a different option just compare the current selection with default selection.
I have an application where I have Tab Host. I have certainly four tabs in my Tab Host and one of my tab contains a list of some elements. Now When a user click on the element of the third Tab he is supposed to switched to the first tab and the data of the list element gets displayed there. But when the user initially tries to click on the first Tab without selecting any element from the list of third tab, I need to display the Alert Message that "Please select an item form the List"
I wonder how to do that particularly?
Thanks,
david
use AlertDialog.
Toast.makeText(this,"Please select an item form the List",Toast.LENGTH_LONG).show();
use it on your click event.
You can use any of the above, but I feel its the logic that you're more interested in.
You might be having four different activities for each tab.
Create on more class, which will serve as your Bean class, which holds all the data to transfer information between classes.
Call this class as PrefBean.
Make all its variables static (as of now you'll be using only one to know whether user has selected any list item, and if yes, which one). This way, the variables will be globally available to all of your activities.
Have an integer in PrefBean which depicts whether something is selected or not in your third tab.
The logic goes as this:
Initially, your integer in PrefBean will hold something less than zero (say -1). This will show that nothing is selected as of then.
When user clicks in the first tab, your first activity will be invoked and it should check the value of that integer in PrefBean, display an error message to the user. If the value is negative, means nothing is selected, if its positive, it will give you the position of the row selected. Load anything depending on the row position selected
When user clicks on any row in your third tab's list activity, set your PrefBean integer == the row position selected.
I hope you got the logic