Hi I am try to write a code in android where I have a 2 seekbars and I want to store the values obtained from seekbars and would like to use it in another screen. So can any help me how to do it. I am using global variables because I want store the values untill the I store I reuse them. Here is my code so please any one tell me how to do that.
package com.example.newairways;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.SeekBar.OnSeekBarChangeListener;
public class relationship extends Activity implements OnSeekBarChangeListener {
private String Q1a,Q1b;
private SeekBar mSeekBar1, mSeekBar2;
private TextView tv1, tv2;
private Button ok,nextQ,cancel;
private ProgressDialog dialog = null;
Intent myIntent;
//List<NameValuePair> nameValuePairs= null;
Bundle myValues;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.relationships);
myValues=getIntent().getExtras();
mSeekBar1 = (SeekBar) findViewById(R.id.Q1a);
mSeekBar1.setOnSeekBarChangeListener(this);
mSeekBar2= (SeekBar) findViewById(R.id.Q1b);
mSeekBar2.setOnSeekBarChangeListener(this);
tv1 = (TextView)findViewById(R.id.Ans1a);
tv2 = (TextView)findViewById(R.id.Ans1b);
TextView welcomeMsg = (TextView)findViewById(R.id.username);
welcomeMsg.setText("name : "+myValues.getString("value"));
ok = (Button)findViewById(R.id.ok);
nextQ = (Button)findViewById(R.id.nextquestion);
cancel= (Button)findViewById(R.id.cancel);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
switch (seekBar.getId())
{
case R.id.Q1a:
tv1.setText(Integer.toString(progress)+"%") ;
Toast.makeText(relationship.this, "Seekbar Value : " + progress, Toast.LENGTH_SHORT).show();
break;
case R.id.Q1b:
tv2.setText(Integer.toString(progress)+"%") ;
Toast.makeText(relationship.this, "Seekbar Value : " + progress, Toast.LENGTH_SHORT).show();
break;
}
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
}