I have already shown how to use seekBar in android.
This simple snippet helps you to get the current progress in the seekbar.
It’s same code from this post, only thing is I added the getProgress method.
This simple snippet helps you to get the current progress in the seekbar.
It’s same code from this post, only thing is I added the getProgress method.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| package com.coderzheaven; <span class = "IL_AD" id= "IL_AD5" > import </span> android.app.Activity; import android.os.Bundle; import android.widget.SeekBar; import android.widget.TextView; public <span class = "IL_AD" id= "IL_AD3" > class </span> SeekBarDemo extends Activity implements SeekBar.OnSeekBarChangeListener { SeekBar mSeekBar; TextView mProgressText; TextView mTrackingText; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.main); mSeekBar = (SeekBar)findViewById(R.id.<span class = "IL_AD" id= "IL_AD7" >seek</span>); int p = mSeekBar.getProgress(); System.out.println( "Current Progress = " + p); mSeekBar.setOnSeekBarChangeListener( this ); mProgressText = (TextView)findViewById(R.id.progress); mTrackingText = (TextView)findViewById(R.id.<span class = "IL_AD" id= "IL_AD1" >tracking</span>); } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { mProgressText.setText(progress + " " + getString(R.string.seekbar_from_touch) + "=" + fromTouch); System.out.println( "onProgressChanged >> Current Progress = " + progress); } public void onStartTrackingTouch(SeekBar seekBar) { mTrackingText.setText(getString(R.string.seekbar_tracking_on)); } public void onStopTrackingTouch(SeekBar seekBar) { mTrackingText.setText(getString(R.string.seekbar_tracking_off)); } } |
No comments:
Post a Comment