@vladocc

Как создать всплывающее меню с EditText в Android?

Мне необходимо, чтобы по нажатии клавиши появлялось меню, небольшим размеров (т.е. не на весь экран), в котором будет TextView, EditText и Button. Каким образом такое реализуется, я не совсем понимаю, по этому задаю к более опытным людям вопрос. Каким образом это сделать?

Есть предположение, что это просто переход к новой активность у которой стоит тема. что-то вроде "@android:style/Theme.DeviceDefault.Dialog.MinWidth". Верна ли эта идея или есть гораздо более простые способы?
  • Вопрос задан
  • 1348 просмотров
Решения вопроса 2
@PaulWeb
вот хорошая библиотека Material dialogs, И еще не много да и вот ссылка на demo для оценки demo

Dialog.Builder builder = new SimpleDialog.Builder(){
            @Override
            protected void onBuildDone(Dialog dialog) {
                dialog.layoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
            @Override
            public void onNegativeActionClicked(DialogFragment fragment) {
                super.onNegativeActionClicked(fragment);
            }

            @Override
            public void onPositiveActionClicked(final DialogFragment fragment) {
                final EditText codeField = (EditText) fragment.getDialog().findViewById(R.id.facCode);
                final View panelProgress=fragment.getDialog()
                        .findViewById(R.id.facProgressPanel);
                final ProgressView progress=(ProgressView)fragment.getDialog()
                        .findViewById(R.id.facProgress);
                if (Is.empty(codeField)) {
                    App.showMessage(R.string.warn_fields);
                    return;
                }
                ......
            }
        };

        builder.title(App.getResStr(R.string.activation))
                .positiveAction(App.getResStr(R.string.send))
                .negativeAction(App.getResStr(R.string.cancel))
                .contentView(R.layout.fragment_activation);
        DialogFragment fragment = DialogFragment.newInstance(builder);
        fragment.show(context.getSupportFragmentManager(), null);


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="5dp" >

    <EditText
        android:id="@+id/facCode"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/hint_activation"
        android:layout_centerInParent="true"
        android:inputType="number"
        android:singleLine="true"
        android:textSize="16sp" />
    <LinearLayout
        android:id="@+id/facProgressPanel"
        android:orientation="horizontal"
        android:gravity="center"
        android:visibility="gone"
        android:background="@color/xxxxxx"
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.rey.material.widget.ProgressView
            android:id="@+id/facProgress"
            style="?attr/xxxxxxx

            />
    </LinearLayout>
</RelativeLayout>
Ответ написан
@lopatoid
TextView, EditText и Button не на весь экран?
Похоже на обычный AlertDialog.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы