[android-developers] Re: Seekbar Save state and restore

2013-07-15 Thread Keith Zettler
I am trying to save the actual position of 200 seekbars on one activity. I 
think this means i have to save/restore the position of the seekbars and 
the integer value of the seekbar before the activity was paused? i had read 
the API and it made no reference to seekbars . I was not aware they were 
widgets nor that i could store their positions and int value in shared 
preferences or that shared preferences even existed. Thank you Fred for 
that. What would be the correct way to accomplish the above TreKing?
Thank you both for your time and efforts 

On Thursday, July 11, 2013 10:14:38 PM UTC-4, Keith Zettler wrote:
>
> How exactly can i save/restore this seekbar if user uses back button or 
> activity is destyroyed?
> I have not been able to find a specific example anywhere
>
>
> public class MainActivity extends Activity  implements 
> SeekBar.OnSeekBarChangeListener {
>
> SeekBar seekBar;
> SeekBar seekBar1;
> TextView textView;
> TextView textView1;
> TextView textView2;
> TextView textView3;
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_main);
>
> seekBar=(SeekBar)findViewById(R.id.seekbar);
> seekBar1=(SeekBar)findViewById(R.id.seekBar1);
> textView=(TextView)findViewById(R.id.textview);
> textView1=(TextView)findViewById(R.id.textView1);
> textView2=(TextView)findViewById(R.id.textView2);
> textView3=(TextView)findViewById(R.id.textView3);
>
>
> 
> seekBar.setOnSeekBarChangeListener(this);
> 
> }
>
> @Override
> public void onProgressChanged(SeekBar seekBar, int progress,
> boolean fromUser) {
> //  Notify that the progress level has changed.
> 
> int A= (progress+250);
> textView.setText("SeekBar now at the value of:"+progress);
> textView1.setText("SeekBar now at the value of:"+A);
> 
>
> }
>
> @Override
> public void onStartTrackingTouch(SeekBar seekBar) {
> // Notify that the user has started a touch gesture.
> //textView.setText(textView.getText()+"\n"+"SeekBar Touch 
> Started");
>
> }
>
> @Override
> public void onStopTrackingTouch(SeekBar seekBar) {
> // Notify that the user has finished a touch gesture.
>// textView.setText(textView.getText()+"\n"+"SeekBar Touch 
> Stopped");   
> }
> 
>
> 
> 
> @Override
> public boolean onCreateOptionsMenu(Menu menu) {
> // Inflate the menu; this adds items to the action bar if it is 
> present.
> getMenuInflater().inflate(R.menu.main, menu);
> return true;
> }
> 
> 
> }
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Seekbar Save state and restore

2013-07-15 Thread TreKing
On Mon, Jul 15, 2013 at 9:45 PM, Keith Zettler wrote:

> I am trying to save the actual position of 200 seekbars on one activity.


Two *hundred*? In *one* activity? Jesus. That does not seem right ... but
hey, it's your app.

I think this means i have to save/restore the position of the seekbars and
> the integer value of the seekbar


Yes...


> before the activity was paused?


No. *After*. See the activity lifecyle:
http://developer.android.com/guide/components/activities.html#Lifecycle

Pay special attention to the part about saving state.


> i had read the API and it made no reference to seekbars .


You're quite hung up on these Seekbars. Again, these are just another
widget like any other - there's nothing special about them that would
require special mention of how to handle saving and restoring their state.

What would be the correct way to accomplish the above TreKing?


Read the links I gave you, then implement the correct methods to save and
restore (onSaveInstanceState, onRestoreInstanceState, respectively) the
states of your seekbars.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.