Пример #1
0
        public virtual bool onLongClick(android.view.View v)
        {
            if (hasText())
            {
                // Don't show the cheat sheet for items that already show text.
                return(false);
            }
            int[] screenPos = new int[2];
            android.graphics.Rect displayFrame = new android.graphics.Rect();
            getLocationOnScreen(screenPos);
            getWindowVisibleDisplayFrame(displayFrame);
            android.content.Context context = getContext();
            int width       = getWidth();
            int height      = getHeight();
            int midy        = screenPos[1] + height / 2;
            int screenWidth = context.getResources().getDisplayMetrics().widthPixels;

            android.widget.Toast cheatSheet = android.widget.Toast.makeText(context, mItemData
                                                                            .getTitle(), android.widget.Toast.LENGTH_SHORT);
            if (midy < displayFrame.height())
            {
                // Show along the top; follow action buttons
                cheatSheet.setGravity(android.view.Gravity.TOP | android.view.Gravity.RIGHT, screenWidth
                                      - screenPos[0] - width / 2, height);
            }
            else
            {
                // Show along the bottom center
                cheatSheet.setGravity(android.view.Gravity.BOTTOM | android.view.Gravity.CENTER_HORIZONTAL
                                      , 0, height);
            }
            cheatSheet.show();
            return(true);
        }