Android Spinner To Change Setcontentview
So, I have a spinner with two different options thus far. What I am trying to accomplish is, if 'First Spinner Option' is chosen, then I setContentView to a specific layout and exe
Solution 1:
I don't know exactly what the problem is you are having but its pretty close. You just need to add the method
@OverridepublicvoidonItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
TextView tv = (TextView)arg1; // get the TextView selectedString text = tv.getText().toString();
if(text.equals("FirstText")){ // compare the text in the boxsetContentView(R.layout.lay1);
//other code here
}elseif(text.equals("FirstText")){
setContentView(R.layout.lay2);
//other code here
}
}
There are different ways of doing this such as getting the position (arg2
) and comparing that to what's in your adapter but since I don't know how you are doing any of that, this is the easiest way to get you started.
Post a Comment for "Android Spinner To Change Setcontentview"