Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java

private void showAddrEnterDialog() {
    // Set the current dialog
    currentDialog = ADDRESS_ENTER_DIALOG_ID;

    // Build Address Enter Dialog
    AlertDialog.Builder addrEnterBuilder = new AlertDialog.Builder(this);
    addrEnterBuilder.setTitle("Step 3: Enter Location Name / Address");

    // Initialize EditText for user to type the desired address
    addressET = new EditText(this);
    addressET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    addrEnterBuilder.setView(addressET);

    // Set Listeners
    addrEnterBuilder.setPositiveButton("Search", mAddrEnterOnClickListner);
    // Finish the activity when the user presses cancel
    addrEnterBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            setResult(RESULT_OK);//  w w w . ja v  a2  s. com
            finish();
        }
    });
    addrEnterBuilder.setOnKeyListener(mBackKeyListener);

    // Show Address Enter Dialog
    addrEnterDialog = addrEnterBuilder.create();
    addrEnterDialog.show();
}

From source file:com.example.android.cardreader.MainActivity.java

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

    //TODO Stop Executing Eden
    //Globals.executeEden();
    getUsers(1);/*from  w  w w. ja v a  2 s  .c o m*/

    instance = this;
    final ActionBar actionBar = getActionBar();
    actionBar.setTitle("           TartanHacks");
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
    actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg));
    actionBar.setDisplayShowHomeEnabled(true);

    frags.add(new PersonListFrag(Globals.pending));
    frags.add(new PersonListFrag(Globals.allUsers));
    frags.add(new PersonListFrag(Globals.checkedIn));

    mAdapter = new FragmentAdapter(getFragmentManager());

    fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View dialogView = View.inflate(instance, R.layout.dialog_signup, null);

            idField = (EditText) dialogView.findViewById(R.id.andrewIdField);
            pb = (ProgressBar) dialogView.findViewById(R.id.progress);
            nameField = (TextView) dialogView.findViewById(R.id.name);
            scanView = (TextView) dialogView.findViewById(R.id.scan_view);

            idField.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    String id = s.toString();
                    pb.setVisibility(View.VISIBLE);
                    queryId(id);

                }

                @Override
                public void afterTextChanged(Editable s) {

                }
            });

            AlertDialog.Builder builder;
            builder = new AlertDialog.Builder(instance);
            builder.setView(dialogView);
            builder.setCancelable(true);
            builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    Globals.adding = false;
                }
            });

            signupDialog = builder.show();
        }
    });

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(0);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this));

    mLoyaltyCardReader = new LoyaltyCardReader(this);

    // Disable Android Beam and register our card reader callback
    enableReaderMode();

    new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor());
}

From source file:com.almunt.jgcaap.systemupdater.MainActivity.java

public void LicencesDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Open Source Licenses");
    WebView wv = new WebView(this);
    wv.loadUrl("file:///android_asset/open_source_licenses.html");
    wv.setWebViewClient(new WebViewClient() {
        @Override//from  ww w.  j  ava 2  s  . c o  m
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    alert.setView(wv);
    alert.setPositiveButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });
    alert.show();
}

From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java

private void renamePlaylistDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setText(mPlaylist.getName());//w  w w.j  av a 2s.  c  o  m
    alert.setView(input);

    alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            ProviderConnection conn = PluginsLookup.getDefault().getProvider(mPlaylist.getProvider());
            if (conn != null) {
                IMusicProvider provider = conn.getBinder();
                if (provider != null) {
                    try {
                        provider.renamePlaylist(mPlaylist.getRef(), value);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Cannot rename playlist", e);
                    } catch (Exception e) {
                        Sentry.captureException(new Exception("Rename playlist: Plugin error", e));
                    }
                }
            }
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
        }
    });

    alert.show();
}

From source file:com.example.drugsformarinemammals.ViewPager_Pinnipeds.java

private void displayMessage(String messageTitle, String message) {
    AlertDialog.Builder myalert = new AlertDialog.Builder(this);

    TextView title = new TextView(this);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setTextSize(20);/* w w  w. j a v a2s  .  co m*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText("");
    title.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout layout = new LinearLayout(this);
    TextView text = new TextView(this);
    text.setTypeface(Typeface.SANS_SERIF);
    text.setTextSize(20);
    text.setPadding(10, 10, 10, 10);
    text.setText(message);
    layout.addView(text);

    myalert.setView(layout);
    myalert.setCustomTitle(title);
    myalert.setCancelable(true);
    myalert.show();

}

From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java

private void createPinDialog() {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.enter_pin, null);
    enterPinText = findById(view, R.id.enterPin);
    pinText = findById(view, R.id.pin);/*from  w ww .  j  a va 2 s  .  com*/
    pinText.setHint(Token.PinType.PIN2.name());
    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setPositiveButton(R.string.sign_button, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            tokenService.readCert(Token.CertType.CertSign, new CertificateInfoCallback());
        }
    }).setNegativeButton(R.string.cancel, null);
    builder.setView(view);
    pinDialog = builder.create();
}

From source file:com.degreat.apps.kwamelearn.CorrectWrongDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    int whatTo = getArguments().getInt(WHAT_TO);

    View solImage = null;//from  ww w. j  a  v a  2  s.c  o m
    switch (whatTo) {
    case GameFragment.CORRECT:
        solImage = inflater.inflate(R.layout.correct_view, null);
        break;

    case GameFragment.WRONG:
        solImage = inflater.inflate(R.layout.wrong_view, null);
        break;

    case GameFragment.INDICATE_LEVEL:
        int level = getArguments().getInt(LEVEL);

        solImage = inflater.inflate(R.layout.level_show, null);
        TextView levelNumber = (TextView) solImage.findViewById(R.id.level_number);
        levelNumber.setText("" + level);
        break;

    /*case GameFragment.RETARD:
        solImage = inflater.inflate(R.layout.retard_view, null);
        break;*/
    }

    builder.setView(solImage);

    return builder.create();
}

From source file:de.baumann.hhsmoodle.data_random.Random_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_screen_dice, container, false);

    ImageView imgHeader = (ImageView) rootView.findViewById(R.id.imageView_header);
    helper_main.setImageHeader(getActivity(), imgHeader);

    fab_dice = (FloatingActionButton) rootView.findViewById(R.id.fab_dice);
    lv = (ListView) rootView.findViewById(R.id.list);
    viewPager = (ViewPager) getActivity().findViewById(R.id.viewpager);
    lvItems = (ListView) rootView.findViewById(R.id.lvItems);

    fabLayout1 = (LinearLayout) rootView.findViewById(R.id.fabLayout1);
    fabLayout2 = (LinearLayout) rootView.findViewById(R.id.fabLayout2);
    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    FloatingActionButton fab1 = (FloatingActionButton) rootView.findViewById(R.id.fab1);
    FloatingActionButton fab2 = (FloatingActionButton) rootView.findViewById(R.id.fab2);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override//from w  ww  .j  a v a 2s  .  c o m
        public void onClick(View view) {
            if (!isFABOpen) {
                showFABMenu();
            } else {
                closeFABMenu();
            }
        }
    });

    fab1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            closeFABMenu();

            android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
            View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_entry, null);

            final EditText edit_title = (EditText) dialogView.findViewById(R.id.note_title_input);
            edit_title.setHint(R.string.title_hint);

            final EditText edit_cont = (EditText) dialogView.findViewById(R.id.note_text_input);
            edit_cont.setHint(R.string.text_hint);

            builder.setView(dialogView);
            builder.setTitle(R.string.number_edit_entry);
            builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {

                    String inputTitle = edit_title.getText().toString().trim();
                    String inputCont = edit_cont.getText().toString().trim();

                    if (db.isExist(inputTitle)) {
                        Snackbar.make(lv, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG).show();
                    } else {
                        db.insert(inputTitle, inputCont, "", "", helper_main.createDate());
                        dialog.dismiss();
                        setRandomList();
                        Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show();
                    }
                }
            });
            builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            });

            final android.app.AlertDialog dialog2 = builder.create();
            // Display the custom alert dialog on interface
            dialog2.show();
            helper_main.showKeyboard(getActivity(), edit_title);
        }
    });

    fab2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            closeFABMenu();
            Intent mainIntent = new Intent(getActivity(), Popup_courseList.class);
            mainIntent.setAction("courseList_random");
            startActivity(mainIntent);
        }
    });

    fab_dice.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            try {
                Random rand = new Random();
                final int n = rand.nextInt(lvItems.getCount());

                setAdapter(n);
                lvItems.setSelection(n - 1);

            } catch (NumberFormatException nfe) {
                nfe.printStackTrace();
            }
        }
    });

    //calling Notes_DbAdapter
    db = new Random_DbAdapter(getActivity());
    db.open();

    setRandomList();
    setHasOptionsMenu(true);

    return rootView;
}

From source file:com.example.cody.tapwater.activities.MainActivity.java

/**
 * If there is no logged in user, displays the log in prompt.
 *///from   w  ww  .  ja  v a2s  .  co m
public void login() {

    // Check if a user exists in the database. If not, user is prompted to log in
    Cursor c = null;
    try {
        c = datasource.query(true, TapOpenHelper.USER_TABLE_NAME, null, null, null, null, null, null, null);
    } catch (Exception e) {

        // If this call fails, this is first use. Create the database
        TapOpenHelper th = new TapOpenHelper(MainActivity.this);
        SQLiteDatabase db = th.getReadableDatabase();
        th.onCreate(db);
    }

    // No users exist in database
    if (c != null && c.getCount() == 0) {
        AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setTitle("Login");

        // Get login dialog layout
        LayoutInflater inflater = this.getLayoutInflater();
        View v = inflater.inflate(R.layout.login, null);

        // Instantiate EditTexts for username and password.
        final EditText username = (EditText) v.findViewById(R.id.username);
        final EditText password = (EditText) v.findViewById(R.id.password);

        b.setView(v);
        b.setPositiveButton("Login", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        b.setNegativeButton("Register", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        alert = b.create();

        alert.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                Button login = alert.getButton(DialogInterface.BUTTON_POSITIVE);
                Button register = alert.getButton(DialogInterface.BUTTON_NEGATIVE);
                login.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        // Make sure EditTexts are not empty
                        if (username.getText().toString().equals("")) {
                            Toast.makeText(getBaseContext(), "Please enter email address", Toast.LENGTH_SHORT)
                                    .show();
                        } else if (password.getText().toString().equals("")) {
                            Toast.makeText(getBaseContext(), "Please enter license number", Toast.LENGTH_SHORT)
                                    .show();
                        } else {
                            // Create User object and set fields needed for async
                            Gson gson = new Gson();
                            User u = new User();
                            u.setUsername(username.getText().toString());
                            u.setPassword(password.getText().toString());

                            // Create json string of activation object
                            String json = gson.toJson(u, User.class);

                            // Begin async to authenticate the user's credentials
                            AuthenticateUserAsync async = new AuthenticateUserAsync(context, new CallBack());

                            // If internet connection exists, DO IT, else, tell user they need to connect
                            if (helper.haveNetworkConnection()) {
                                async.execute(json);
                            } else {
                                Toast.makeText(getBaseContext(), "No Network Connection", Toast.LENGTH_LONG)
                                        .show();
                            }
                        }
                    }
                });

                // If user clicks register, bring up the registration prompt.
                register.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        alert.dismiss();
                        register();
                    }
                });
            }

        });

        // Show the prompt, if the user cancels, close the application
        alert.show();
        alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });

    } else {
        // If user is already logged in, get their information and set the textviews on the main activity
        user = datasource.getUser();
    }
}

From source file:com.aniruddhc.acemusic.player.Dialogs.RenamePlaylistDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();/*from   w  w  w.ja  v  a2s .co m*/
    dialog = this;

    //Retrieve the arguments.
    final String PLAYLIST_NAME = getArguments().getString("PLAYLIST_NAME");
    final String PLAYLIST_FILE_PATH = getArguments().getString("PLAYLIST_FILE_PATH");
    final String PLAYLIST_FOLDER_PATH = getArguments().getString("PLAYLIST_FOLDER_PATH");

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    dialogView = parentActivity.getLayoutInflater().inflate(R.layout.rename_playlist_dialog_layout, null);

    playlistInfo = (TextView) dialogView.findViewById(R.id.rename_playlist_info);
    playlistInfo.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistInfo.setPaintFlags(playlistInfo.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistNameField = (EditText) dialogView.findViewById(R.id.rename_playlist_text_field);
    playlistNameField.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameField.setPaintFlags(
            playlistNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistNameField.setText(PLAYLIST_NAME);

    //Set the dialog title.
    builder.setTitle(R.string.rename_playlist);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialog.dismiss();

        }

    });

    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            //Create a File that points to the playlist on the filesystem.
            File file = new File(PLAYLIST_FILE_PATH);

            //Retrieve the name and file path for the playlist.
            String playlistName = playlistNameField.getText().toString();

            //Replace illegal characters in the playlistName.
            if (playlistName.contains("/")) {
                playlistName = playlistName.replace("/", "_");
            }

            if (playlistName.contains("\\")) {
                playlistName = playlistName.replace("\\", "_");
            }

            //Create another File that points to the renamed playlist file.
            File newFile = new File(PLAYLIST_FOLDER_PATH + "/" + playlistName + ".m3u");
            file.renameTo(newFile);

            /*//Update the database with the new file path and playlist name.
            DBAccessHelper playlistsDBHelper = new DBAccessHelper(parentActivity);
            playlistsDBHelper.renamePlaylist(PLAYLIST_FILE_PATH, playlistName, newFile.getAbsolutePath());
                    
            //Delete any instances of the old DB entries.
            playlistsDBHelper.deleteSpecificPlaylist(PLAYLIST_NAME, PLAYLIST_FILE_PATH);*/

            Toast.makeText(parentActivity, R.string.playlist_renamed, Toast.LENGTH_SHORT).show();

            //Refresh the playlists list view.
            //PlaylistsFragment playlistsFragment = new PlaylistsFragment();
            //playlistsFragment.refreshPlaylists();

            //playlistsDBHelper.close();
            dialog.dismiss();
        }

    });

    return builder.create();
}