Android PopupWindow 实例

public PoiRangeWind(Context context, String POIKey, View view,
			MKSearch mkSearch) {
		mAppContext = AppContext.getInstance();
		this.POIKey = POIKey;
		this.mkSearch = mkSearch;
		LayoutInflater inflater = LayoutInflater.from(context);
		poiView = inflater.inflate(R.layout.poi_range, null);
		poiRangeWind = new PopupWindow(poiView, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT);
		poiView.setFocusable(true);
		poiView.setFocusableInTouchMode(true);
		poiRangeWind.setFocusable(true);
		poiRangeWind.setOutsideTouchable(true);
		poiRangeWind.setBackgroundDrawable(new BitmapDrawable());
		defRange = (TextView) poiView.findViewById(R.id.defult_range);
		rangeText1 = (TextView) poiView.findViewById(R.id.range1);
		rangeText2 = (TextView) poiView.findViewById(R.id.range2);
		rangeText3 = (TextView) poiView.findViewById(R.id.range3);
		rangeText4 = (TextView) poiView.findViewById(R.id.range4);
		defRange.setOnClickListener(clickListener);
		rangeText1.setOnClickListener(clickListener);
		rangeText2.setOnClickListener(clickListener);
		rangeText3.setOnClickListener(clickListener);
		rangeText4.setOnClickListener(clickListener);
		poiRangeWind.setAnimationStyle(R.style.PopupAnimation);
		poiRangeWind.showAsDropDown(view);
		poiView.setOnKeyListener(new OnKeyListener() {

			@Override
			public boolean onKey(View view, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					poiRangeWind.dismiss();
					poiRangeWind = null;
					return true;
				}
				return false;
			}
		});
	}

你可能感兴趣的:(Android PopupWindow 实例)