Please can anyone help me, well i'm working on application that: when someone is calling it shows you a layout containing some Infos, inside that layout there's a close a button that when i click it, it should hide the layout or destroy the app, my probleme is the layout shows but the button is unclickable, it's just like an image of the button. this is my code:
@Override
public void onCreate() {
super.onCreate();
toastLayout = (ViewGroup)layoutInflater.inflate(R.layout.toast, null);
defaultPopupHorizontalGravity = getResources().getInteger(R.integer.default_popup_horizontal_gravity);
defaultPopupVerticalGravity = getResources().getInteger(R.integer.default_popup_vertical_gravity);
//defaultPopupMap = Boolean.parseBoolean(getResources().getString(R.string.default_popup_map));
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE//FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,//FLAG_NOT_TOUCHABLE
PixelFormat.TRANSLUCENT
);
Button X = (Button) toastLayout.getChildAt(0);
toastLayout.addView(X);
X.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("Clicked----><<<<<<<");
}
});
X.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
System.out.println("Touched =----- > ");
return false;
}
});
windowManager.addView(toastLayout, params);