ondrovic
Newbie
So I am new to developing android apps and had a question. I have a spinner and based on the selection I was wondering the best way to call another class / layout.
Here is my main class
So based on the selection from the spinner I want it to call another activity / go to another layout
I also have other classes defined FamilyPlansActivity and IndividualPlansActivity
So am I even on the right path? Any advice would be greatly appreciated
Thanks
Here is my main class
Code:
public class BestBuyMobileActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitialSetup();
}
public void InitialSetup() {
Spinner spinner = (Spinner) findViewById(R.id.planSelector);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.plan_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new PlanSelectionListener());
}
class PlanSelectionListener implements OnItemSelectedListener {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
//Display Selected option
Toast.makeText(parent.getContext(), parent.getItemAtPosition(pos).toString() + " selected ", Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> parent) {
}
}
}
So based on the selection from the spinner I want it to call another activity / go to another layout
I also have other classes defined FamilyPlansActivity and IndividualPlansActivity
Code:
public class FamilyPlansActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.individual);
}
}
Code:
public class IndividualPlansActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.individual);
}
}
So am I even on the right path? Any advice would be greatly appreciated
Thanks