// Linkify the message final SpannableString s = new SpannableString(msg); Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(activity) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage( s ) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
final AlertDialog d = new AlertDialog.Builder(this) .setPositiveButton(android.R.string.ok, null) .setIcon(R.drawable.icon) .setMessage(Html.fromHtml("<a href=\"http://www.google.com\">Check this link out</a>")) .create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
AlertDialog alert = builder.create(); alert.show(); TextView msgTxt = (TextView) alert.findViewById(android.R.id.message); msgTxt.setTextSize(16.0);
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("My Title"); builder.setMessage("your message"); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageText = (TextView)dialog.findViewById(android.R.id.message); messageText.setGravity(Gravity.CENTER); dialog.show();
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=dlg.findViewById(R.id.title); EditText value=dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask().execute(values); }
@Override public void onClick(DialogInterface dialog, int which) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)dialog; EditText title=(EditText)dlg.findViewById(R.id.title); EditText value=(EditText)dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); task=new InsertTask(getActivity()).execute(values); }
public void onClick(DialogInterface di, int whichButton) { ContentValues values=new ContentValues(2); AlertDialog dlg=(AlertDialog)di; EditText title=dlg.findViewById(R.id.title); EditText value=dlg.findViewById(R.id.value); values.put(DatabaseHelper.TITLE, title.getText().toString()); values.put(DatabaseHelper.VALUE, value.getText().toString()); final ContentResolver cr=getActivity().getContentResolver(); new Thread() { @Override public void run() { cr.insert(Provider.Constants.CONTENT_URI, values); } }.start(); }
Button submit = (Button) findViewById(R.id.submitButton); submit.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(Application1GoodExample.this); builder.setMessage("Your form has been successfully submitted"); builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // this will solve your error AlertDialog alert = builder.create(); alert.show(); alert.getWindow().getAttributes(); TextView textView = (TextView) alert.findViewById(android.R.id.message); textView.setTextSize(40); Button btn1 = alert.getButton(DialogInterface.BUTTON_NEGATIVE); btn1.setTextSize(16); } });
@Test public void shouldDelegateToDialogFindViewByIdIfViewIsNull() { AlertDialog dialog = new AlertDialog(context) {}; assertThat((View) dialog.findViewById(99)).isNull(); dialog.setContentView(R.layout.main); assertNotNull(dialog.findViewById(R.id.title)); }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle(R.string.deviceDetails); DeviceDisplay deviceDisplay = (DeviceDisplay)l.getItemAtPosition(position); dialog.setMessage(deviceDisplay.getDetailsMessage()); dialog.setButton( getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } } ); dialog.show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); textView.setTextSize(12); super.onListItemClick(l, v, position, id); }
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("TEST MESSAGE) .setPositiveButton("YES", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); ((Button)alert.findViewById(android.R.id.button1)).setBackgroundResource(R.drawable.button_border);
public static void colorAlertDialogTitle(AlertDialog dialog, int color) { int dividerId = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); if (dividerId != 0) { View divider = dialog.findViewById(dividerId); divider.setBackgroundColor(color); } int textViewId = dialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null); if (textViewId != 0) { TextView tv = (TextView) dialog.findViewById(textViewId); tv.setTextColor(color); } int iconId = dialog.getContext().getResources().getIdentifier("android:id/icon", null, null); if (iconId != 0) { ImageView icon = (ImageView) dialog.findViewById(iconId); icon.setColorFilter(color); } }
/** * Saves current tab index and fragment states. */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); FragmentManager fm = getSupportFragmentManager(); Consumer<Fragment> putFragment = fragment -> { if (fragment != null && fragment.isAdded()) { fm.putFragment(outState, fragment.getClass().getName(), fragment); } }; putFragment.accept(mFolderListFragment); putFragment.accept(mDeviceListFragment); putFragment.accept(mDrawerFragment); outState.putInt("currentTab", mViewPager.getCurrentItem()); outState.putBoolean(BATTERY_DIALOG_DISMISSED, mBatteryOptimizationsDialog == null || !mBatteryOptimizationsDialog.isShowing()); outState.putBoolean(IS_SHOWING_RESTART_DIALOG, mRestartDialog != null && mRestartDialog.isShowing()); if(mQrCodeDialog != null && mQrCodeDialog.isShowing()) { outState.putBoolean(IS_QRCODE_DIALOG_DISPLAYED, true); ImageView qrCode = mQrCodeDialog.findViewById(R.id.qrcode_image_view); TextView deviceID = mQrCodeDialog.findViewById(R.id.device_id); outState.putParcelable(QRCODE_BITMAP_KEY, ((BitmapDrawable) qrCode.getDrawable()).getBitmap()); outState.putString(DEVICEID_KEY, deviceID.getText().toString()); } Util.dismissDialogSafe(mRestartDialog, this); }
@Test public void testWiFiBandFilterViewIsVisible() { // setup fixture.show(); // execute int actual = alertDialog.findViewById(R.id.filterWiFiBand).getVisibility(); // validate assertEquals(View.VISIBLE, actual); }
@Test public void testStrengthFilterViewIsVisible() { // setup fixture.show(); // execute int actual = alertDialog.findViewById(R.id.filterStrength).getVisibility(); // validate assertEquals(View.VISIBLE, actual); } }