我正在我的 上制作一个对话框EditText
,所以当我触摸 时EditText
,该框将显示 (setOntouchListener)。问题是:当我触摸 时EditText
,该框显示两次(当我单击框中的关闭按钮时,第二个框显示并且框的内容完全相同)
FoodText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.customfoodinput);
dialog.setTitle("Insert your Food");
spinner1 = (Spinner) dialog.findViewById(R.id.spinner_foodTime);
spinner2 = (Spinner) dialog.findViewById(R.id.spinner_foodType);
foodtimeArray.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(foodtimeArray);
foodtypeArray.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(foodtypeArray);
Button btntampung = (Button) dialog.findViewById(R.id.btn_inputfood);
btntampung.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Object item = spinner1.getSelectedItem();
String dataspinner = item.toString();
Object item2 = spinner2.getSelectedItem();
String dataspinner2 = item2.toString();
dialog.dismiss();
FoodText.setText(dataspinner + "; " + dataspinner2);
}
});
dialog.show();
return false;
}
});
任何人都可以帮助我吗?