import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
+import android.widget.PopupWindow;
import android.widget.TextView;
public class TooltipPopup {
private final Context mContext;
+ private final PopupWindow mPopupWindow;
private final View mContentView;
private final TextView mMessageView;
public TooltipPopup(Context context) {
mContext = context;
+ mPopupWindow = new PopupWindow(context);
+ mPopupWindow.setBackgroundDrawable(null);
mContentView = LayoutInflater.from(mContext).inflate(
com.android.internal.R.layout.tooltip, null);
mMessageView = (TextView) mContentView.findViewById(
computePosition(anchorView, anchorX, anchorY, fromTouch, mLayoutParams);
- WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
- wm.addView(mContentView, mLayoutParams);
+ mPopupWindow.setContentView(mContentView);
+ mPopupWindow.showAtLocation(
+ anchorView, mLayoutParams.gravity, mLayoutParams.x, mLayoutParams.y);
}
public void hide() {
if (!isShowing()) {
return;
}
-
- WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
- wm.removeView(mContentView);
+ mPopupWindow.dismiss();
}
public View getContentView() {
}
public boolean isShowing() {
- return mContentView.getParent() != null;
+ return mPopupWindow.isShowing();
}
public void updateContent(CharSequence tooltipText) {