标签:des android style blog http io os ar java
问题描述package com.freeplay.microdiary.activities; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import android.widget.PopupWindow; import android.widget.TextView; import com.freeplay.microdiary.R; import static com.freeplay.microdiary.R.id.edit_All; public class EditActivity extends Activity { private TextView pic_TextView; private TextView location_TextView; private TextView weather_TextView; private PopupWindow mPopupWindow1; private PopupWindow mPopupWindow2; private PopupWindow mPopupWindow3; private TextView lastPic_TextView; private TextView takePhoto_TextView; private TextView cancel_TextView1; private TextView cancel_TextView2; private TextView cancel_TextView3; private TextView pic_Library_TextView; private Context mContext = null; @Override protected void onCreate(Bundle savedInstanceState) { System.out.println("启动EditActivity"); super.onCreate(savedInstanceState); setContentView(R.layout.edit_activity); mContext=this; /* 找到控件 */ pic_TextView = (TextView) findViewById(R.id.pic_TextView); location_TextView = (TextView) findViewById(R.id.location_TextView); weather_TextView = (TextView) findViewById(R.id.weather_TextView); /* PopupWindow相关 */ View popupView1 = getLayoutInflater().inflate(R.layout.pic_menu, null); pic_Library_TextView = (TextView) findViewById(R.id.pic_Library_TextView); pic_Library_TextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { System.out.println("点击了从图库里选择"); } }); mPopupWindow1 = new PopupWindow(popupView1, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, true); mPopupWindow1.setTouchable(true); mPopupWindow1.setOutsideTouchable(true); mPopupWindow1.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null)); mPopupWindow1.setAnimationStyle(R.style.anim_menu_bottombar); /* 图片按钮监听器 */ pic_TextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { System.out.println("图片按钮点击"); /* 呈现三个选项:选取最后一张,拍照,打开图库选择 */ mPopupWindow1.showAtLocation(findViewById(R.id.edit_All), Gravity.BOTTOM, 0, 0); } }); } }
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(); } }); } }
标签:des android style blog http io os ar java
原文地址:http://www.cnblogs.com/shaochuyun57/p/4027418.html