我的工作需要在Android Studio中旋轉部件簡單的Android項目的另一項活動。我想要做的是,當用戶從微調器中選擇選項時,它將打開另一個活動。而我正處於編碼的中間。我決定在Intent中使用開關盒條件。問題是,每當我運行應用程序時,它都會自動轉到我聲明的特定活動位置。即使我沒有選擇任何選擇微調。 注:登錄貓不顯示任何錯誤如何解決自動視圖上微調onItemSelected方法
你的幫助是非常感謝給初學者和我一樣。
public class CustomOnItemSelectedListener extends Activity implements
OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
// **************************** below here is where I start the new activity
switch (pos) {
case 0 :
Intent i = new Intent(app.this, home.class);
app.this.startActivity(i);
break;
case 1 :
//Intent intent = new Intent(app.this, about.class);
//app.this.startActivity(intent);
break;
case 2 :
//Intent intent1 = new Intent(app.this, home.class);
//app.this.startActivity(intent1);
break;
}
// **************************** above here is where I start the new activity
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
請重新標記題! – Aroniaina
@Aroniaina抱歉,我的意思是,當我運行應用程序時,它會自動進入home.class。即使我沒有選擇第一個微調。任何想法如何解決我的問題? –