但我不希望它是dropdown.I想點擊微調,要打開他對話框。 這怎麼辦? 什麼我實現如下微調的ontouch我打開對話框......然而,它也打開下拉菜單,以及 我想禁用下拉列表,並實現它的點擊..Android微調對話框
最後微調serverSpinner =(微調)findViewById(R .id.serverSpinner); String [] array_spinner = new String [2]; array_spinner [0] =「hoho」; array_spinner [1] =「lala」; ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item,array_spinner); serverSpinner.setAdapter(adapter); serverSpinner.setOnTouchListener(新OnTouchListener(){
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
showSpinner();
return false;
}
});
protected void showSpinner() { AlertDialog.Builder b = new Builder(this); String[] options = {"hoho","lala"};
b.setTitle("Select an option");
b.setSingleChoiceItems(options, -1,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
switch(which){
case 0:
{
break;
}
case 1:
{
break;
}
}}
});
b.setPositiveButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
b.show();}
}
我不斷收到這個「不要叫setOnClickListener的一個AdapterView – user3278732