我有一个EditText
视图,
<EditText
android:layout_weight="1"
android:id="@+id/etMiktar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/miktarHint"
android:focusable="false">
</EditText>
我实现了一个弹出窗口,当用户触摸此EditText视图时会打开该窗口。这个弹出窗口有一个按钮,因此当点击弹出窗口时应该被解雇。虽然它获得了我的点击,但弹出窗口并未关闭。 这是我的弹出式实现:
private void inflatePopUpSiparis(){
LayoutInflater inflater = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final PopupWindow pwSiparis = new PopupWindow(inflater.inflate(R.layout.siparismiktarpopup, null, false),400,550,true);
pwSiparis.showAtLocation(this.findViewById(R.id.llMain), Gravity.CENTER, 0, 0);
//pwSiparis.setFocusable(true);
View myPopUpSiparisView = pwSiparis.getContentView();
etSiparisMiktar=(EditText)myPopUpSiparisView.findViewById(R.id.etSiparisMiktar);
etSiparisMiktar.setText(etUrunMiktar.getText().toString());
btnPopUpSiparisTamam=(Button)myPopUpSiparisView.findViewById(R.id.btnPopUpSiparis);
btnPopUpSiparisTamam.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
pwSiparis.dismiss();
Log.d("****",etSiparisMiktar.getText().toString().toString());
etUrunMiktar.setText(etSiparisMiktar.getText().toString());
}
});
}
}
可能是什么问题?
答案 0 :(得分:0)
我使用以下代码启动一个类似于PopUp的自定义对话框。如果您需要,我也可以共享布局文件。 dialog.cancel();
也类似于解雇。
private void showpopup(int popuptype, String message) {
//set up dialog
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog);
//dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
//there are a lot of settings, for dialog, check them all out!
//set up text
TextView text = (TextView) dialog.findViewById(R.id.textViewSubject);
text.setText(message);
//set up button
Button button = (Button) dialog.findViewById(R.id.buttonOK);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.e("Alert", "Nothing");
dialog.dismiss();
}
});
//now that the dialog is set up, it's time to show it
dialog.show();
}
答案 1 :(得分:0)