PopupWindow
2015-11-10 18:24
183 查看
popwindow弹框可以在activity上显示出一个对话框
public class DaoHan {
private String shouye;
private String personinfo;
private String myevent;
private String kaquan;
private String shezhi;
private String kefu;
private Context ct;
private PopupWindow popupWindow;
List data;
private ListView popItemList;
PopupWindowAdapter dadapter;
int width;
int height;
public DaoHan(Context ct) {
this.ct=ct;
initpopdata();
}
public void initpopdata(){
}
public class DaoHan {
private String shouye;
private String personinfo;
private String myevent;
private String kaquan;
private String shezhi;
private String kefu;
private Context ct;
private PopupWindow popupWindow;
List data;
private ListView popItemList;
PopupWindowAdapter dadapter;
int width;
int height;
public DaoHan(Context ct) {
this.ct=ct;
initpopdata();
}
public void initpopdata(){
shouye = ct.getResources().getString(R.string.huidaoshouye); personinfo = ct.getResources().getString(R.string.personinfo); myevent = ct.getResources().getString(R.string.myevent); kaquan = ct.getResources().getString(R.string.kaquan); shezhi = ct.getResources().getString(R.string.shezhi); kefu = ct.getResources().getString(R.string.daohan_kefu); if(data!=null){ data.clear(); } data=new ArrayList<PopupWindowbean>(); data.add(new PopupWindowbean(R.drawable.daohan_zhuye, shouye, R.drawable.arrows)); data.add(new PopupWindowbean(R.drawable.daohan_ziliao, personinfo, R.drawable.arrows)); data.add(new PopupWindowbean(R.drawable.nagi_ticket, kaquan, R.drawable.arrows)); data.add(new PopupWindowbean(R.drawable.daohan_wode,myevent, R.drawable.arrows)); data.add(new PopupWindowbean(R.drawable.daohan_kefu,kefu, R.drawable.arrows)); data.add(new PopupWindowbean(R.drawable.nagi_set, shezhi, R.drawable.arrows)); } public PopupWindow initPopupWindow() { /* 初始化PopupWindow */ View popView = LayoutInflater.from(ct).inflate(R.layout.popupwindow, null, false); // 获取自定义的布局文件 popItemList = (ListView) popView.findViewById(R.id.nagiItem); if(dadapter!=null){ dadapter.notifyDataSetChanged(); }else{ dadapter = new PopupWindowAdapter(ct,data); popItemList.setAdapter(dadapter); popItemList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: new CommonUtils(ct) .startActivity(Main1Activity.class); popupWindow.dismiss(); break; case 1: new CommonUtils(ct) .startActivity(PersonActivity.class); popupWindow.dismiss(); break; case 2: new CommonUtils(ct) .startActivity(MydiscountActivity.class); popupWindow.dismiss(); break; case 3: new CommonUtils(ct) .startActivity(MyActivity.class); popupWindow.dismiss(); break; case 4: new CommonUtils(ct) .startActivity(KeFuActivity.class); popupWindow.dismiss(); break; case 5: new CommonUtils(ct) .startActivity(SafeoutActivity.class); popupWindow.dismiss(); break; default: break; } } }); } WindowManager wm = ((Activity) ct).getWindowManager(); width = wm.getDefaultDisplay().getWidth(); height = wm.getDefaultDisplay().getHeight(); popupWindow = new PopupWindow(popView, width * 2 / 3,ViewGroup.LayoutParams.WRAP_CONTENT, true); // 创建实例 宽度200 高度150 popupWindow.setOutsideTouchable(true); // 设置点击外界关闭popwindow popupWindow.setTouchInterceptor(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return false; } }); popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setFocusable(true); return popupWindow; }
}
相关文章推荐
- 底部Popwindow形式菜单的类的封装
- popwindow 被魅族虚拟键挡住
- android 2.3 popwindow NullPointerException的解决
- 自定义popWindow
- Android应用Activity、Dialog、PopWindow、Toast窗口添加机制及源码分析 《四》-PopWindow
- Android应用Activity、Dialog、PopWindow、Toast窗口添加机制及源码分析 《二》
- popwindow 位置和动画
- android popwindow的使用
- onCreate方法中调用PopupWindow的错误:android.view.WindowManager$BadTo
- Popwindow 使用例子:
- PopWindow使用,,OpinionFeedbackActivity,MyPopWindow,MyProgressDialog,PhotoGridViewAdapter,调用系统的拍照和相册
- 关于popwindow的简单实例
- Android popwindow和fragment结合 左侧弹出下拉菜单 切换界面
- Android中popWindow弹出菜单的编写
- PopWindow的理解
- 【Android】创建Popwindow弹出菜单
- 设置PopWindow显示在某控件之上和无法获取PopWindow高度问题解决方法
- popwindow 加listview OnItemClickListener失效问题
- 实现半透明的popupwindow的源码
- PopupWindow的使用