我有一系列元素的列表视图。 点击列表视图项目会显示一个自定义对话框。 在自定义对话框中,我有一个布局:
这是正常情况:
当我选择微调器时,他会显示一个项目列表。
当我从微调器中选择一个项目时,按钮上的文本会以这种方式消失:
ps:这在Android 6.0上不会发生,但它发生在较低版本(例如5.0)
中守则:
public void showDialogTagAssociation (Activity activity, Handler handler,
String msg, final MyOperator elemento, final BluetoothDevice device,
final int position){
mHandler = handler;
//-----------------------------------------------------
// DIALOG
dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
//-----------------------------------------------------
//---------------------------------------------------------------------
// LAYOUT
dialog.setContentView(R.layout.alert_dialog_custom_tag);
**// Spinner element
spinner = (Spinner) dialog.findViewById(R.id.spinner);**
// Spinner click listener
**spinner.setOnItemSelectedListener(new OnSpinnerItemClicked());**
//---------------------------------------------------------------------
//----------------------------------------------------------------------
// BUTTON OK
dialogButtonOK = (Button) dialog.findViewById(R.id.acd_btn_ok);
dialogButtonOK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "Devo assegnare il tag al nome....");
Log.d(TAG, "Nome: " +tmpNome+"\n" +
"TAG: "+device.getName()+" - "+device.getAddress());
dialog.dismiss();
}
});
// BUTTON ANNULLA
dialogButtonNO = (Button) dialog.findViewById(R.id.acd_btn_no);
dialogButtonNO.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
//----------------------------------------------------------------------
dialog.show();
}
**private class OnSpinnerItemClicked implements android.widget.AdapterView.OnItemSelectedListener {**
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
//NOME
tmpNome = parent.getItemAtPosition(pos).toString();
}
@Override
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
感谢您将来的帮助
答案 0 :(得分:1)
删除那段代码:
spinner.setOnItemSelectedListener(new OnSpinnerItemClicked());
并且您想要的东西仍然可以使用。