OKのpopupwindow demoをテストします


	/**
	 *   PopupWindow
	 */
	public void initPopupWindow() {
		//   PopupWindow     
		LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = layoutInflater.inflate(R.layout.popup, null);
		//   PopupWindow       
		View parentView = layoutInflater.inflate(R.layout.first, null);
		//    PopupWindow    
		// TextView titleTextView = (TextView)
		// view.findViewById(R.id.popup_title);
		// ImageView editImg = (ImageView) view.findViewById(R.id.popup_edit);
		// ImageView listenImg = (ImageView)
		// view.findViewById(R.id.popup_listen);

		// SeekBar seekBar = (SeekBar) view.findViewById(R.id.popup_progress);
		// TextView progressTextView = (TextView) view
		// .findViewById(R.id.popup_progress_tv);
		// view.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
		// LayoutParams.WRAP_CONTENT));
		TextView black=(TextView)view.findViewById(R.id.black_txt);
		black.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (popupWindow != null) {
					popupWindow.dismiss();
				}	
			}
		});
		GridView gridView = (GridView) view.findViewById(R.id.popup_grid);
		GridViewAdapter adapter = new GridViewAdapter(this, mPictures, mTitles);
		gridView.setAdapter(adapter);
		gridView.setOnItemClickListener(new ItemClickListener());
		gridView.setOnItemSelectedListener(new OnItemSelectedListener() {
			/*
			 * (non-Javadoc)
			 * 
			 * @see
			 * android.widget.AdapterView.OnItemSelectedListener#onItemSelected
			 * (android.widget.AdapterView, android.view.View, int, long)
			 */
			@Override
			public void onItemSelected(AdapterView> arg0, View arg1,
					int arg2, long arg3) {
				// TODO Auto-generated method stub

			}

			/*
			 * (non-Javadoc)
			 * 
			 * @see
			 * android.widget.AdapterView.OnItemSelectedListener#onNothingSelected
			 * (android.widget.AdapterView)
			 */
			@Override
			public void onNothingSelected(AdapterView> arg0) {
				// TODO Auto-generated method stub

			}
		});
		//       PopupWindow
		popupWindow = new PopupWindow(view, LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT);
		//  PopupWindow       
		// popupWindow.showAsDropDown(parentView);

		// popupWindow.setBackgroundDrawable(new BitmapDrawable());
		popupWindow.setFocusable(true);
		popupWindow.setTouchable(true);
		// popupWindow.
		// popupWindow.update();
		// popupWindow.setBackgroundDrawable(new BitmapDrawable());
		popupWindow.setOutsideTouchable(true);//        ,      、  、touchable、update
		// popupWindow.set
		popupWindow.setWindowLayoutMode(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT);
		popupWindow.showAtLocation(parentView, Gravity.NO_GRAVITY, 0, 0);
		// popupWindow.setFocusable(true);
		//                  ,  activity         
		// popupWindow.setAnimationStyle(R.style.popup_show_out);
		popupWindow.setAnimationStyle(android.R.style.Animation_Translucent);
		popupWindow.getContentView().findViewById(R.id.main)
				.setOnKeyListener(new OnKeyListener() {

					@Override
					public boolean onKey(View v, int keyCode, KeyEvent event) {
						// TODO Auto-generated method stub
						Log.i("lxm", "key press");
						switch (event.getAction()) {
						case KeyEvent.ACTION_DOWN:
							if (keyCode == KeyEvent.KEYCODE_MENU
									|| keyCode == KeyEvent.KEYCODE_BACK) {
								if (popupWindow != null) {
									popupWindow.dismiss();
								}
							}
							break;
						}
						return false;
					}
				});
	}