Search...

Sunday, November 13, 2011

How to create popup window in android


This popup window will not stop the processing of other screen. You can set the popup location as well.
Example:


PopupWindow pw;
LayoutInflater  inflater=null;

public void showPopup(Activity context) {

try {

inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = inflater.inflate(R.layout.my_custom_popup_layout, null, false);

TextView f=(TextView)layout.findViewById(R.id.textview) ;
                        f.setText("Hello Android");
pw = new PopupWindow(layout, 400, LayoutParams.WRAP_CONTENT, true);
pw.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.my_bg));
pw.setOutsideTouchable(true);
pw.showAtLocation(context.findViewById(R.id.dvrBtn), Gravity.TOP,
395,65);
} catch (Exception e) {
e.printStackTrace();
}
}

No comments:

Post a Comment