关于PopupWindow的两个问题 Popupwindowandroid点击 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); android dialog 关闭 android如何在通话过程中屏蔽home键 关于android的学习 ffmpeg软解码渲染花屏 Android 2.3如何在Windows平台检查Native代码是否有内存泄露? 请问谁有张泽华老师android视频的PPT和笔记 java 和 android 分别与matlab交互编程 android 线程是同时运行还是有先后次序? ndk 如何一次编译多静态库项目(包含静态库存生成源码) incoming call 与 outgoing call 如何让定时器不失效 android 自带浏览iframe中onclick事件触发 问题
@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);