I have a EditText view,
<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>
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());
}
});
}
}
What could be the problem?
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.