0
public class uploadActivity extends Activity implements OnClickListener {
protected void onCreate(Bundle savedInstanceState)
{
Spinner spinner = (Spinner) findViewById(R.id.spinner_list);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.spinner_arrays, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
}
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
Toast.makeText(parent.getContext(), "Selected entry in spinner is : " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT).show();
}
public void onNothingSelected(AdapterView<?> parent) {
}
我試圖微調添加到我的課堂活動,但在我的項目有4個按鈕,對,我需要OnClickListener來實現,我已經完成了它的功能,所以我不能改變onclicklistener到OnItemSelectedListener和即時嘗試波紋管方法,但因爲我沒有實現OnItemSelectedListener。像onItemSelected方法不叫當我點擊入境因此如何在DIS情況下
感謝執行
可以嗎?如何爲每個條目分配值? – andy
喜歡在列表中有人說遊戲,家庭,時尚條目,當我點擊任何一個條目從微調[說遊戲]我想返回一些價值,如遊戲返回值1和家庭2和時尚3等 – andy
@andy在'onItemSelected'裏面的位置變量裏面會返回值1,2,3等, – Hariharan