弹出窗口不会关闭 [英] Pop-up does not dismiss

查看:185
本文介绍了弹出窗口不会关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的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一个弹出窗口。这种弹出窗口有一个按钮,所以点击时应该弹出被解雇。虽然得到我的点击,弹出不会关闭。
这里是我的弹出实现:

And I implemented a pop-up window which opens when the user touches this EditText view. This pop-up window has a button, so when clicked pop-up supposed to be dismissed. Although it gets my clicks, the pop-up does not close. Here is my pop-up implementation:

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());
      }
    });


}

}

这可能是什么问题?

推荐答案

的问题是;我用onTouchListener的EditText上。由于 DMON ,在规定回答对于类似的问题,onTouchListener为着陆和提升响应。所以,当我把它改为onClickListener解决了这个问题。

The problem was; I was using onTouchListener for the EditText. As dmon , stated in the answer for the similar problem, onTouchListener responds for both landing and lifting. So when I changed it to onClickListener the problem solved.

这篇关于弹出窗口不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆