关于PopupWindow的两个问题
2014-10-15 21:38
190 查看
问题描述
第一个问题:PopupWindow里面的控件怎么监听。
第二个问题:怎么实现上下两个PopupWindow同时出现,同时消失,如多看阅读(见下图)
我的项目里是这样的:点击出现一个PopupWindow,但是里面的四个也需要点击监听,我应该怎么做?
我自己是这样写的
然后在activity里 new PopupWindows(UserInfoActivity.this, aiv);
第一个问题:PopupWindow里面的控件怎么监听。
第二个问题:怎么实现上下两个PopupWindow同时出现,同时消失,如多看阅读(见下图)
我的项目里是这样的:点击出现一个PopupWindow,但是里面的四个也需要点击监听,我应该怎么做?
我自己是这样写的
但是这样点开就报错 解决方案1 private class PopupWindows extends PopupWindow { @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.CUPCAKE) @SuppressLint("NewApi") public PopupWindows(Context mContext, View parent) { super(mContext); View view = View.inflate(mContext, R.layout.zhgl_userinfo_avatarupdate, null); view.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.fade_ins)); LinearLayout ll_popup = (LinearLayout) view .findViewById(R.id.ll_popup); ll_popup.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.push_bottom_in_2)); setWidth(LayoutParams.FILL_PARENT); setHeight(LayoutParams.FILL_PARENT); setBackgroundDrawable(new BitmapDrawable()); setFocusable(true); setOutsideTouchable(true); setContentView(view); showAtLocation(parent, Gravity.BOTTOM, 0, 0); update(); Button bt1 = (Button) view .findViewById(R.id.item_popupwindows_camera); Button bt2 = (Button) view .findViewById(R.id.item_popupwindows_Photo); Button bt3 = (Button) view .findViewById(R.id.item_popupwindows_cancel); bt1.setOnClickListener(new OnClickListener() { // 通过相机获得图片 public void onClick(View v) { Intent intentFromCapture = new Intent( MediaStore.ACTION_IMAGE_CAPTURE); intentFromCapture.putExtra( MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment .getExternalStorageDirectory(), "head2.png"))); // intentFromCapture.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, // 1); startActivityForResult(intentFromCapture, CAMERA_REQUEST_CODE); dismiss(); } }); bt2.setOnClickListener(new OnClickListener() { // 从本地选取图片 public void onClick(View v) { Intent intentFromGallery = new Intent(); intentFromGallery.setType("image/*"); // 设置文件类型 intentFromGallery.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intentFromGallery, IMAGE_REQUEST_CODE); dismiss(); } }); bt3.setOnClickListener(new OnClickListener() { public void onClick(View v) { dismiss(); } }); } }
然后在activity里 new PopupWindows(UserInfoActivity.this, aiv);
相关文章推荐
- 关于PopupWindow的两个问题
- 关于PopupWindow的两个问题
- 关于RICHEDIT的两个问题
- [全程建模]与一个朋友讨论的关于书上的两个问题
- 急需解决------关于在两个窗体之间传递参数的问题---------解决了
- 关于 IE 模态对话框的两个问题
- [导入]转:两个关于.NET读取EXCEL文件的问题
- 关于输入法的两个问题
- 关于ASP.NET2.0 WebPart两个问题的解决...
- 关于 IE 模态对话框的两个问题
- wormhole-two 关于虫洞路由交换机制的两个问题和解决方法
- 关于c#中两个DataGrid绑定到主表和子表的数据同步问题
- 关于C#中实现两个应用程序消息通讯的问题
- 关于 Windows Mobile 5.0 的两个问题
- 关于MSDE 的两个问题
- 关于C#中实现两个应用程序消息通讯的问题
- 关于两个ListBox绑定数据库后的联动问题(我先抛块砖)
- 今天解决了两个关于.NET读取EXCEL文件的问题,记下来,很有用!
- 关于两个对象交换的问题
- 关于两个对象交换的问题(实践的角度)