Onseekbarchangelistener Always Evaluates To Null In Android
I have an android program that I am making with 4 seekbars, and 4 textviews to accompany each seekbar. Right now, I am trying to make each textview's contents equal to the integer
Solution 1:
Move your setContentView(R.layout.main);
before initializing your variables. Your onCreate
method should look like this
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv1 = (TextView) findViewById(R.id.textView1);
tv2 = (TextView) findViewById(R.id.textView2);
tv3 = (TextView) findViewById(R.id.textView3);
tv4 = (TextView) findViewById(R.id.textView4);
sb1 = (SeekBar) findViewById(R.id.seekBar1);
sb2 = (SeekBar) findViewById(R.id.seekBar2);
sb3 = (SeekBar) findViewById(R.id.seekBar3);
sb4 = (SeekBar) findViewById(R.id.seekBar4);
sb1.setOnSeekBarChangeListener(OnSeekBarProgress);
sb2.setOnSeekBarChangeListener(OnSeekBarProgress);
sb3.setOnSeekBarChangeListener(OnSeekBarProgress);
sb4.setOnSeekBarChangeListener(OnSeekBarProgress);
}
Post a Comment for "Onseekbarchangelistener Always Evaluates To Null In Android"