0
首先,我對此很新,所以請耐心等待。 我想做一個微調,如果你選擇一個項目,佈局和活動會改變,但我甚至不能實現最簡單的微調。改變微調器的佈局和活動
到目前爲止,我已經得到的唯一代碼是下面的代碼,但不管我輸入什麼都沒有做任何事情,所以我必須不理解它,請在您的答案中非常具體。謝謝。第一個答案了我一些方法,但「旋轉器的旋轉..... spin.setAdapter(AA)」部分未在OnCreate
String[] generations = { "Gen2", "Gen3", "Gen4", "Gen5", "Gen6","Gen7" };
Spinner spin = (Spinner) findViewById(R.id.spinner1);
spin.setOnItemSelectedListener(this);
ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,generations);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//Setting the ArrayAdapter data on the Spinner
spin.setAdapter(aa);
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 1:
Intent intent2 = new Intent(this, gen2.class);
startActivity(intent2);
break;
case 2:
Intent intent3 = new Intent(this, Gen3.class);
startActivity(intent3);
break;
case 3:
Intent intent4 = new Intent(this, gen4.class);
startActivity(intent4);
break;
case 4:
Intent intent5 = new Intent(this, gen5.class);
startActivity(intent5);
break;
case 5:
Intent intent6 = new Intent(this, MainActivity.class);
startActivity(intent6);
break;
case 6:
Intent intent7 = new Intent(this, gen7.class);
startActivity(intent7);
break;
}
}
它讓我更接近,所以非常感謝你。 它仍然不會改變任何東西,它不會改變佈局,它不會改變類 – Runesen