Mainactivity.java 这是调用三种方法的主要活动
public class MainActivity extends Activity {
Button b = (Button) findViewById(R.id.button);
public TextView t = (TextView) findViewById(R.id.postp);
public Spinner catspinner,planspinner1,planspinner2;
protected void onCreate(Bundle mbfSplash) {
super.onCreate(mbfSplash);
setContentView(R.layout.activity_main);
chooseCategory();
chooseone();
choosetwo();
}
public void chooseCategory() {
catspinner = (Spinner) findViewById(R.id.catspinner);
ArrayAdapter<CharSequence> catAdapter = ArrayAdapter.createFromResource(this, R.array.states_array, android.R.layout.simple_spinner_item);
catAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
catspinner.setAdapter(catAdapter);
catspinner.setOnItemSelectedListener(new planOnClickListener());
}
private void chooseone(){
planspinner1 = (Spinner) findViewById(R.id.planspinner);
List<String> planlist = new ArrayList<String>();
planlist.add("Mandu");
planlist.add("Chanderi");
planlist.add("Jabalpur");
planlist.add("Orccha");
planlist.add("Bhopal");
ArrayAdapter<String> planAdapter1 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, planlist);
planAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
planspinner1.setAdapter(planAdapter1);
}
private void choosetwo(){
planspinner2 = (Spinner) findViewById(R.id.planspinner);
List<String> planlist1 = new ArrayList<String>();
planlist1.add("Premier Plan");
planlist1.add("The Executive Plan");
planlist1.add("Business Circle Plan");
planlist1.add("Business Diamond Plan");
ArrayAdapter<String> planAdapter2 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, planlist1);
planAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
planspinner2.setAdapter(planAdapter2);
}
public class planOnClickListener implements OnItemSelectedListener {
@Override
public void onItemSelected(AdapterView<?> parent, View v, int pos,
long id) {
final int p = pos;
parent.getItemAtPosition(pos);
if (pos==0){
choosePersonalPlan();
}else if (pos==1){
chooseLargeBusPlan();
} else if (pos==2){
chooseSmallMedPlan();
}
/*Intent intent = new Intent(new Intent("com.example.android.testing.SecondActivity"));
intent.putExtra("value",str);
//---set the data to pass back---
//data.setData(Uri.parse(str));
//setResult(RESULT_OK, data);
//---closes the activity---
//finish();
startActivity(intent);*/
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
choosecategory()方法从spinner
中提供一个选定的项目在第一个微调项目的基础上选择下一个方法(即第二个微调器取决于微调器一个)
第二种方法可以选择1或选择2
通过planOnClickListener中的onItemSelected方法帮助选择方法
感谢您的帮助...
答案 0 :(得分:0)
将你的额外内容传递给你的意图
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("key","value");
startActivity(intent);