這裏是代碼: 幫助我們,我只是新來的。非常感謝!我很難找到解決方案..非常感謝,非常感謝。 它應該鏈接到相同的XML佈局。我有一個動態的微調,如果我點擊微調項目,我想鏈接到另一個佈局
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
db = new DatabaseHelper(MainActivity.this);
edittext = (EditText) findViewById(R.id.editText1);
btnAdd = (Button) findViewById(R.id.btnadd);
spinner = (Spinner) findViewById(R.id.spinner1);
btnAdd.setOnClickListener(this);
spinner.setOnItemSelectedListener(this);
/* when spinner item is clicked it should linked to another layout.. it should link in add_student layout
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String str = (String) arg0.getSelectedItem();
//here print selected value...
System.out.println("String is :: " + str);
//And StartActivity here...
Intent intent = new Intent(MainActivity.this,StudentActivity.class);
startActivity(intent);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
*/
}
}
你的概率是多少? –
在這裏告訴你的問題。你需要什麼? – Piyush
轉到[this](http://stackoverflow.com/questions/19948487/android-how-to-get-value-from-spinner-and-based-on-value-to-redirect-to-anothe/19948697 #19948697)頁面。 它可能會幫助你.. –