Java Code Examples for android.support.v7.app.AlertDialog#findViewById()

The following examples show how to use android.support.v7.app.AlertDialog#findViewById() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapActivity.java    From snazzymaps-browser with Apache License 2.0 6 votes vote down vote up
/**
 * Shows a dialog that provides information about the style, such as its author and URL.
 */
private void showInfoDialog() {
    String desc = mStyle.description.split(" ").length > 3 ? mStyle.description + "\n\n" : "";
    final SpannableString message = new SpannableString(getString(
            R.string.info_dialog_message, desc, mStyle.url));
    Linkify.addLinks(message, Linkify.ALL);

    final AlertDialog dialog = new AlertDialog.Builder(this)
            .setPositiveButton(android.R.string.ok, null)
            .setTitle(getString(R.string.info_dialog_title, mStyle.name, mStyle.author))
            .setMessage(message)
            .create();
    dialog.show();

    TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
    messageView.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 2
Source File: ControlHelper.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void showProDialog(final Context context) {
    AlertDialog builder = new AlertDialog.Builder(context)
            .setTitle(R.string.pro_user_only)
            .setMessage(R.string.get_pro)
            .setPositiveButton(R.string.login, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent intent = new Intent(context, NGIDLoginActivity.class);
                    context.startActivity(intent);
                }
            })
            .setNegativeButton(android.R.string.cancel, null)
            .show();

    TextView message = builder.findViewById(android.R.id.message);
    if (message != null) {
        message.setMovementMethod(LinkMovementMethod.getInstance());
        message.setLinksClickable(true);
    }
}
 
Example 3
Source File: CrashReportActivity.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    final AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle(R.string.crash_dialog_title)
            .setView(R.layout.crash_report_dialog)
            .setPositiveButton(R.string.ok, this)
            .setNegativeButton(R.string.cancel, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnDismissListener(this);
    dialog.show();

    comment = (EditText) dialog.findViewById(android.R.id.input);
    if (savedInstanceState != null) {
        comment.setText(savedInstanceState.getString(STATE_COMMENT));
    }
}
 
Example 4
Source File: ProjectManagerActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * show dialog with file info
 * filePath, path, size, extension ...
 *
 * @param file - file to show info
 */
private void showFileInfo(File file) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(file.getName());
    builder.setView(R.layout.dialog_view_file);
    AlertDialog dialog = builder.create();
    dialog.show();
    TextView txtInfo = dialog.findViewById(R.id.txt_info);
    txtInfo.setText(file.getPath() + "\n" +
            file.length() + " byte");
    EditorView editorView = dialog.findViewById(R.id.editor_view);
    if (editorView != null && FileUtils.canEdit(file)) {
        editorView.setTextHighlighted(mFileManager.fileToString(file));
    }
}
 
Example 5
Source File: WifiListActivity.java    From WiFiKeyShare with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    int itemPosition = ((ContextMenuRecyclerView.RecyclerContextMenuInfo) item.getMenuInfo()).position;
    switch (item.getItemId()) {
        case (R.id.context_menu_wifi_list_view_password):
            final AlertDialog viewPasswordDialog = new AlertDialog.Builder(this)
                    .setTitle(getString(R.string.wifilist_dialog_view_password))
                    .setView(R.layout.dialog_view_password)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();
            viewPasswordDialog.show();

            /* Set SSID, security and password values */
            TextView ssidTextView = (TextView) viewPasswordDialog.findViewById(R.id.ssid_value);
            TextView authTypeTextView = (TextView) viewPasswordDialog.findViewById(R.id.auth_type_value);
            TextView passwordTextView = (TextView) viewPasswordDialog.findViewById(R.id.password_value);
            ssidTextView.setText(wifiNetworks.get(itemPosition).getSsid());
            authTypeTextView.setText(wifiNetworks.get(itemPosition).getAuthType().toString());
            passwordTextView.setText(wifiNetworks.get(itemPosition).getKey());
            passwordTextView.setTextIsSelectable(true);
            return true;
        case (R.id.context_menu_wifi_list_clear_password):
            removeSavedWifiKey(itemPosition);
            return true;
    }

    return super.onContextItemSelected(item);
}
 
Example 6
Source File: WifiNetworkActivity.java    From WiFiKeyShare with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_view_password:
            // FIXME: redundant with @WifiListActivity#onContextItemSelected
            final AlertDialog viewPasswordDialog = new AlertDialog.Builder(this)
                    .setTitle(getString(R.string.wifi_dialog_view_password))
                    .setView(R.layout.dialog_view_password)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();
            viewPasswordDialog.show();

            /* Set SSID, security and password values */
            TextView ssidTextView = (TextView) viewPasswordDialog.findViewById(R.id.ssid_value);
            TextView authTypeTextView = (TextView) viewPasswordDialog.findViewById(R.id.auth_type_value);
            TextView passwordTextView = (TextView) viewPasswordDialog.findViewById(R.id.password_value);
            ssidTextView.setText(wifiNetwork.getSsid());
            authTypeTextView.setText(wifiNetwork.getAuthType().toString());
            passwordTextView.setText(wifiNetwork.getKey());
            passwordTextView.setTextIsSelectable(true);
            return true;
        case R.id.action_settings:
            startActivity(new Intent(this, SettingsActivity.class));
            return true;
        case R.id.action_about:
            final AlertDialog aboutDialog = new AboutDialog(this);
            aboutDialog.show();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 7
Source File: SslErrorDialogFragment.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
private void showExtendedMessage(@NonNull AlertDialog alertDialog) {
    TextView textView = (TextView) alertDialog.findViewById(android.R.id.message);
    Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    if (textView != null) {
        textView.setText(R.string.ssl_error_display_message_extended);
        neutralButton.setEnabled(false);
    }
}
 
Example 8
Source File: HostPreference.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDialogCreated(final AlertDialog dialog) {
  final EditText host = dialog.findViewById(R.id.host);
  host.setText(Settings.getCustomizedAcHost());

  Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
  button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      String url = host.getText().toString();

      if (url.startsWith("http://") || url.startsWith("https://")) {
        // Remove ending '/'
        while (url.charAt(url.length() - 1) == '/') {
          url = url.substring(0, url.length() - 1);
        }

        if (url.charAt(4) == 's' ? url.length() > 8 : url.length() > 7) {
          Settings.putCustomizedAcHost(url);
          dialog.dismiss();
          return;
        }
      }

      Toast.makeText(dialog.getContext(), R.string.main_customized_ac_host_invalid, Toast.LENGTH_SHORT).show();
    }
  });
}