Search in sources :

Example 76 with PopupWindow

use of android.widget.PopupWindow in project BaseProject by fly803.

the class ViewUtils method showPopupWindow.

/**
 * 显示PopupWindow
 * @param context
 * @param resId
 * @param root
 * @param paramsType
 * @return
 */
public static View showPopupWindow(Context context, int resId, View root, int paramsType) {
    View popupView;
    popupView = LayoutInflater.from(context).inflate(resId, null);
    switch(paramsType) {
        case 1:
            popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
            break;
        case 2:
            popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
            break;
        case 3:
            popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
            break;
        case 4:
            popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
            break;
        default:
            popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
            break;
    }
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setTouchable(true);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.showAsDropDown(root);
    return popupView;
}
Also used : PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextView(android.widget.TextView)

Example 77 with PopupWindow

use of android.widget.PopupWindow in project BaseProject by fly803.

the class NiceSpinner method init.

private void init(Context context, AttributeSet attrs) {
    Resources resources = getResources();
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NiceSpinner);
    int defaultPadding = resources.getDimensionPixelSize(R.dimen.one_and_a_half_grid_unit);
    setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
    setPadding(resources.getDimensionPixelSize(R.dimen.three_grid_unit), defaultPadding, defaultPadding, defaultPadding);
    setClickable(true);
    backgroundSelector = typedArray.getResourceId(R.styleable.NiceSpinner_backgroundSelector, R.drawable.selector);
    setBackgroundResource(backgroundSelector);
    textColor = typedArray.getColor(R.styleable.NiceSpinner_textTint, getDefaultTextColor(context));
    setTextColor(textColor);
    listView = new ListView(context);
    // Set the spinner's id into the listview to make it pretend to be the right parent in
    // onItemClick
    listView.setId(getId());
    listView.setDivider(null);
    listView.setItemsCanFocus(true);
    // hide vertical and horizontal scrollbars
    listView.setVerticalScrollBarEnabled(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position >= selectedIndex && position < adapter.getCount()) {
                position++;
            }
            // Need to set selected index before calling listeners or getSelectedIndex() can be
            // reported incorrectly due to race conditions.
            selectedIndex = position;
            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(parent, view, position, id);
            }
            if (onItemSelectedListener != null) {
                onItemSelectedListener.onItemSelected(parent, view, position, id);
            }
            adapter.setSelectedIndex(position);
            setTextInternal(adapter.getItemInDataset(position).toString());
            dismissDropDown();
        }
    });
    popupWindow = new PopupWindow(context);
    popupWindow.setContentView(listView);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        popupWindow.setElevation(DEFAULT_ELEVATION);
        popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.spinner_drawable));
    } else {
        popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.drop_down_shadow));
    }
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            if (!isArrowHidden) {
                animateArrow(false);
            }
        }
    });
    isArrowHidden = typedArray.getBoolean(R.styleable.NiceSpinner_hideArrow, false);
    arrowDrawableTint = typedArray.getColor(R.styleable.NiceSpinner_arrowTint, Integer.MAX_VALUE);
    arrowDrawableResId = typedArray.getResourceId(R.styleable.NiceSpinner_arrowDrawable, R.drawable.arrow);
    dropDownListPaddingBottom = typedArray.getDimensionPixelSize(R.styleable.NiceSpinner_dropDownListPaddingBottom, 0);
    typedArray.recycle();
    measureDisplayHeight();
}
Also used : ListView(android.widget.ListView) TypedArray(android.content.res.TypedArray) PopupWindow(android.widget.PopupWindow) AdapterView(android.widget.AdapterView) Resources(android.content.res.Resources) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 78 with PopupWindow

use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.

the class SkillFragment method setupSettings.

private void setupSettings() {
    final Button btnSettings = (Button) m_root.findViewById(R.id.btnSettings);
    btnSettings.setVisibility(View.VISIBLE);
    btnSettings.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            final PopupWindow pw = Util.showPopup(getActivity(), R.layout.skill_settings, true, btnSettings, 5, 5);
            View v = pw.getContentView();
            Button btn = (Button) v.findViewById(R.id.btn_learning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentSkills();
                }
            });
            btn = (Button) v.findViewById(R.id.btn_unlearning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentUnlearn();
                }
            });
        }
    });
}
Also used : Button(android.widget.Button) PopupWindow(android.widget.PopupWindow) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 79 with PopupWindow

use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.

the class UnlearnFragment method setupSettings.

private void setupSettings() {
    final Button btnSettings = (Button) m_root.findViewById(R.id.btnSettings);
    btnSettings.setVisibility(View.VISIBLE);
    btnSettings.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            final PopupWindow pw = Util.showPopup(getActivity(), R.layout.skill_settings, true, btnSettings, 5, 5);
            View v = pw.getContentView();
            Button btn = (Button) v.findViewById(R.id.btn_learning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentSkills();
                }
            });
            btn = (Button) v.findViewById(R.id.btn_unlearning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentUnlearn();
                }
            });
        }
    });
}
Also used : Button(android.widget.Button) PopupWindow(android.widget.PopupWindow) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 80 with PopupWindow

use of android.widget.PopupWindow in project smoke by textbrowser.

the class MemberChat method showDetailsOfMessage.

private void showDetailsOfMessage(int oid) {
    if (MemberChat.this.isFinishing())
        return;
    else if (m_lastContextMenuPosition[0] < 0 || m_lastContextMenuPosition[1] < 0)
        return;
    class SingleShot implements Runnable {

        private int m_oid = -1;

        SingleShot(int oid) {
            m_oid = oid;
        }

        @Override
        public void run() {
            MemberChat.this.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    PopupWindow popupWindow = new PopupWindow(MemberChat.this);
                    String string = s_databaseHelper.messageDetails(m_oid).trim();
                    TextView textView1 = new TextView(MemberChat.this);
                    float density = getApplicationContext().getResources().getDisplayMetrics().density;
                    textView1.setBackgroundColor(Color.rgb(255, 255, 255));
                    textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
                    textView1.setTextSize(16);
                    if (string.isEmpty())
                        textView1.setText("Cannot retrieve message details.");
                    else
                        textView1.setText(string);
                    popupWindow.setContentView(textView1);
                    popupWindow.setOutsideTouchable(true);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
                        popupWindow.setHeight(450);
                        popupWindow.setWidth(700);
                    }
                    popupWindow.showAtLocation(findViewById(R.id.recycler_view), Gravity.START | Gravity.TOP, m_lastContextMenuPosition[0], m_lastContextMenuPosition[1]);
                    m_lastContextMenuPosition[0] = m_lastContextMenuPosition[1] = -1;
                }
            });
        }
    }
    Thread thread = new Thread(new SingleShot(oid));
    thread.start();
}
Also used : PopupWindow(android.widget.PopupWindow) TextView(android.widget.TextView)

Aggregations

PopupWindow (android.widget.PopupWindow)145 View (android.view.View)68 TextView (android.widget.TextView)52 ColorDrawable (android.graphics.drawable.ColorDrawable)29 Paint (android.graphics.Paint)26 ImageView (android.widget.ImageView)24 AdapterView (android.widget.AdapterView)15 Key (android.inputmethodservice.Keyboard.Key)14 LayoutInflater (android.view.LayoutInflater)14 LinearLayout (android.widget.LinearLayout)14 ListView (android.widget.ListView)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)13 Button (android.widget.Button)13 Activity (android.app.Activity)12 Context (android.content.Context)11 Resources (android.content.res.Resources)11 OnClickListener (android.view.View.OnClickListener)11 ViewGroup (android.view.ViewGroup)11 EditText (android.widget.EditText)11 ScrollView (android.widget.ScrollView)10