Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

In this page you can find the example usage for android.app Dialog setContentView.

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:com.infamous.site.activity.MainActivity.java

public Dialog getChangelog() {
    final Dialog CDialog = new Dialog(MainActivity.this);
    CDialog.setTitle(getResources().getString(R.string.changelog_title));
    CDialog.setContentView(R.layout.changelog);
    CDialog.setCanceledOnTouchOutside(true);
    CDialog.setCancelable(true);/*from   w  ww.j  a  v a2 s  .com*/

    Button Close = (Button) CDialog.findViewById(R.id.close);
    Close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CDialog.dismiss();
        }
    });

    return CDialog;
}

From source file:com.memetro.android.MainActivity.java

public void showRecoverPassDialog(final Context context) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.dialog_recover);
    mDialog.setCancelable(true);/* w ww .  j  a  v a 2  s  .c o m*/

    final EditText emailText = (EditText) mDialog.findViewById(R.id.email);
    Button sendButton = (Button) mDialog.findViewById(R.id.send);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            RecoverPassUtils.recoverPass(context, emailText.getText().toString(), new OAuthHandler() {
                public void onStart() {
                    pdialog.show();
                }

                public void onSuccess() {
                    mDialog.dismiss();
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ok));
                }

                public void onFailure() {
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ko));
                }

                public void onFinish() {
                    pdialog.dismiss();
                }
            });
        }
    });

    mDialog.show();
}

From source file:com.slownet5.pgprootexplorer.filemanager.listview.FileSelectionManagement.java

void openFile(final String filename) {
    if (SharedData.IS_IN_COPY_MODE) {
        return;//from  w  ww  .j  a va2 s  .  c o m
    }
    if (FileUtils.isEncryptedFile(filename)) {
        Log.d(TAG, "openFile: File name is: " + filename);
        if (SharedData.KEY_PASSWORD == null) {
            final Dialog dialog = new Dialog(mContext);
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.password_dialog_layout);
            dialog.show();
            dialog.findViewById(R.id.cancel_decrypt_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                }
            });
            final EditText editText = (EditText) dialog.findViewById(R.id.key_password);
            dialog.findViewById(R.id.decrypt_file_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (editText.getText().length() < 1) {
                        editText.setError("please give me your encryption password");
                        return;
                    } else {
                        SharedData.KEY_PASSWORD = editText.getText().toString();
                        dialog.dismiss();
                        new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWORD, SharedData.USERNAME,
                                filename, SharedData.KEY_PASSWORD).execute();
                    }

                }
            });
        } else {
            new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWORD, SharedData.USERNAME, filename,
                    SharedData.KEY_PASSWORD).execute();
        }

    } else {
        UiUtils.openFile(filename, mContext, mFileListAdapter);
    }
}

From source file:com.ivalentin.margolariak.SettingsLayout.java

private void showDialog(String title, String text) {
    //Create the dialog
    final Dialog dialog = new Dialog(getActivity());

    //Set up dialog window
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_settings);

    //Set the custom dialog components - text, image and button
    TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_settings_title);
    WebView wvText = (WebView) dialog.findViewById(R.id.wv_dialog_settings_text);

    if (Build.VERSION.SDK_INT >= 19) {
        wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } else {/*www.  j  av  a 2s.co  m*/
        wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    Button btClose = (Button) dialog.findViewById(R.id.bt_dialog_settings_close);

    //Set text
    tvTitle.setText(title);
    wvText.loadDataWithBaseURL(null, text, "text/html", "utf-8", null);

    //Set close button
    btClose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    //Set parameters
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER;
    lp.dimAmount = 0.4f;
    dialog.getWindow().setAttributes(lp);

    //Show dialog
    dialog.show();

}

From source file:com.minerva.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    checkAndRequestPermissions();/*from   w  w  w  . j a va2  s .  com*/

    LOG_TAG = MainActivity.this.getClass().getSimpleName();

    Log.i(LOG_TAG, "Creating application Main Activity...");

    // *** Setting up the Toolbar ***
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // *** Handling navigation buttons and clicks ***
    BottomNavigationView bottomNavigationVew = (BottomNavigationView) findViewById(R.id.navigation);
    bottomNavigationVew
            .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch (item.getItemId()) {
                    case R.id.action_camera:
                        Log.i(LOG_TAG, "Accessing Camera Activity...");
                        Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
                        startActivity(cameraIntent);
                        break;
                    case R.id.action_gallery:
                        Log.i(LOG_TAG, "Accessing Gallery Activity...");
                        Intent galleryIntent = new Intent(MainActivity.this, GalleryActivity.class);
                        startActivity(galleryIntent);
                        break;
                    case R.id.action_home:
                        break;
                    }

                    return false;
                }
            });

    // *** Handling first time use ***

    SharedPreferences settings = getSharedPreferences(PREFS_NAME1, 0);

    //if (settings.getBoolean("my_first_time1", false)) {
    //the app is being launched for first time, do something

    // *** First time task ***
    final Dialog alertDialog = new Dialog(this);
    alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alertDialog.setContentView(R.layout.navigation);
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    alertDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);

    alertDialog.show();

    Button gotIt = (Button) alertDialog.findViewById(R.id.gotIt);
    gotIt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
        }
    });
    // record the fact that the app has been started at least once
    //  settings.edit().putBoolean("my_first_time", false).commit();
}

From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.learning_card_overview_activity);
    this.initControls();

    this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() {
        @Override/*w w w .j  av a  2s.  c  o  m*/
        public void onClick(View v) {
            final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining();
            if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) {
                final Dialog dialog = new Dialog(LearningCardOverviewActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.learning_card_dialog);
                dialog.setCancelable(true);

                final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries);
                final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>(
                        getApplicationContext(), android.R.layout.simple_spinner_item,
                        MainActivity.globals.getSqLite().getLearningCardQueries(""));
                spLearningCardQuery.setAdapter(learningCardQueries);
                learningCardQueries.notifyDataSetChanged();

                final Button btnStartSop = dialog.findViewById(R.id.cmdStart);
                btnStartSop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        learningCardQueryTraining.setLearningCardQuery(
                                learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition()));
                        learningCardQueryTraining.setID(MainActivity.globals.getSqLite()
                                .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining));
                        cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end));
                        fragmentAdapter.setQuery(learningCardQueryTraining);
                        viewPager.setAdapter(fragmentAdapter);
                        dialog.dismiss();
                    }
                });
                dialog.show();
            } else {
                int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0;
                LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite()
                        .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0);
                for (LearningCardQueryResult result : reloadedTraining.getResults()) {
                    if (result.isResult1() || result.isResult2() || result.isResult3()) {
                        rightCards++;
                        if (result.isResult1()) {
                            firstTry++;
                        } else if (result.isResult2()) {
                            secondTry++;
                        } else {
                            thirdTry++;
                        }
                    } else {
                        wrongCards++;
                    }
                }
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        LearningCardOverviewActivity.this);
                alertDialogBuilder.setTitle(R.string.learningCard_result);
                String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n",
                        getString(R.string.learningCard_result_right), rightCards,
                        getString(R.string.learningCard_result_wrong), wrongCards,
                        getString(R.string.learningCard_result_firstTry), firstTry,
                        getString(R.string.learningCard_result_secondTry), secondTry,
                        getString(R.string.learningCard_result_thirdTry), thirdTry);
                alertDialogBuilder.setMessage(content);
                alertDialogBuilder.create().show();

                cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query));
                fragmentAdapter.setQuery(null);
                viewPager.setAdapter(fragmentAdapter);
            }
        }
    });
}

From source file:com.amazon.appstream.fireclient.ErrorDialogFragment.java

/**
 * Standard initialization. Sets up the dialog to quit the
 * activity on clicking its only button.
 *//*from  w  w w. j  av a 2s . c o m*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Dialog dialog = new Dialog(getActivity());

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    dialog.getWindow().setBackgroundDrawable(ConnectDialogFragment.mEmpty);
    dialog.setContentView(R.layout.fatal_error);

    final Button signin = (Button) dialog.findViewById(R.id.signin);
    final TextView message = (TextView) dialog.findViewById(R.id.message);

    message.setText(mMessage);

    signin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

            ((FireClientActivity) getActivity()).openConnectDialog(null);
        }
    });

    return dialog;
}

From source file:com.amazon.appstream.sampleclient.ErrorDialogFragment.java

/**
 * Standard initialization. Sets up the dialog to quit the
 * activity on clicking its only button.
 *///from  w  ww. j av  a  2s .com
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Dialog dialog = new Dialog(getActivity());

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    dialog.getWindow().setBackgroundDrawable(ConnectDialogFragment.mEmpty);
    dialog.setContentView(R.layout.fatal_error);

    final Button signin = (Button) dialog.findViewById(R.id.signin);
    final TextView message = (TextView) dialog.findViewById(R.id.message);

    message.setText(mMessage);

    signin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

            ((SampleClientActivity) getActivity()).openConnectDialog(null);
        }
    });

    return dialog;
}

From source file:no.barentswatch.fiskinfo.MyPageActivity.java

private void createSettingsDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.dialog_settings);
    dialog.setTitle(R.string.settings);//from   w  w  w . ja v a 2  s.co m

    Button setStoragePathButton = (Button) dialog.findViewById(R.id.settings_dialog_set_storage_path_button);
    Button logOutButton = (Button) dialog.findViewById(R.id.settings_dialog_log_out_button);
    Button okButton = (Button) dialog.findViewById(R.id.settings_dialog_ok_button);

    setStoragePathButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            createFileDialog();
        }
    });

    logOutButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            createConfirmLogoutDialog(getContext(), R.string.log_out, R.string.confirm_log_out);
        }
    });

    okButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:cn.apputest.ctria.section2.Dialog_DriverLicenseCard.java

public void alert_DriverLicenseCardDialog(Context context, EditText carnum) {
    // TODO Auto-generated method stub
    contextAlawys = context;//from w  w w.  j a v a  2 s. c o  m

    preferencesuser = context.getSharedPreferences(Login.FILE_USER, Context.MODE_PRIVATE);
    String DBName = preferencesuser.getString(Login.KEY_NAME, "1");
    helper = new DBHelper(context, DBName + "_DB");
    mgr = new DBManager(helper);

    final Dialog dialog = new Dialog(context, R.style.add_dialog);
    View vv = LayoutInflater.from(context)
            .inflate(R.layout.section2activity_lucha2_alert_driverlicensecard_dialog, null);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(vv);
    // dialog.getWindow().setLayout(480, 524);
    // dialog.getWindow().setLayout(720, 1050);
    Resources r = context.getResources();
    int x = (int) r.getDimension(R.dimen.x320);
    int y = (int) r.getDimension(R.dimen.y350);
    dialog.getWindow().setLayout(x, y);
    dialog.getWindow().setGravity(Gravity.BOTTOM);

    Information = (TextView) vv.findViewById(R.id.DriverLicensecard);
    Information.setClickable(false);
    Information.setLongClickable(false);
    Information.setMovementMethod(ScrollingMovementMethod.getInstance());

    getDriverLicense(carnum);
    ImageButton backButton = (ImageButton) vv.findViewById(R.id.backImageButton);
    backButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();
        }
    });
    dialog.show();
}