List of usage examples for android.app AlertDialog show
public void show()
From source file:nl.terr.tabweave.TabWeave.java
public void fillData(List<JSONObject> lTabs) { // Create an array to specify the fields we want to display in the list (only TITLE) String[] from = new String[] { SyncWeave.KEY_TITLE, SyncWeave.KEY_URL, SyncWeave.KEY_ROWID }; // and an array of the fields we want to bind those fields to (in this case just text1) int[] to = new int[] { R.id.title, R.id.url }; int iBrowserInstances = lTabs.size(); MatrixCursor matrixCursor = new MatrixCursor(from); int iTabId = 0; // Show "No tabs" message TextView tvNoTabs = (TextView) findViewById(R.id.no_tabs); tvNoTabs.setVisibility(View.VISIBLE); try {/* ww w.j av a 2 s.c o m*/ for (int iWeaveBrowserInstance = 0; iWeaveBrowserInstance < iBrowserInstances; iWeaveBrowserInstance++) { int iNumberTabs = lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").length(); // Hide "No tabs" message if (iNumberTabs > 0) { tvNoTabs.setVisibility(View.INVISIBLE); } for (int iWeaveTab = 0; iWeaveTab < iNumberTabs; iWeaveTab++) { matrixCursor.newRow() .add(lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").getJSONObject(iWeaveTab) .getString("title")) .add(lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").getJSONObject(iWeaveTab) .getJSONArray("urlHistory").getString(0)) .add(iTabId); iTabId++; } } } catch (Exception e) { e.printStackTrace(); AlertDialog alert = createAlertDialog(this, e.getClass().toString(), e.getMessage()); alert.show(); } ListAdapter listAdapter = new SimpleCursorAdapter(this, // Context R.layout.tab_row, // Specify the row template to use (here, two columns bound to the two retrieved cursor rows). matrixCursor, from, to); setListAdapter(listAdapter); }
From source file:ab.util.AbDialogUtil.java
/** * AlertDialog ??/*from w ww . j ava2 s . c o m*/ */ public static AlertDialog getAlertDialogWithoutRemove(Context mContext, int layout, double showWidth) { final AlertDialog alerDialog = new AlertDialog.Builder(mContext).create(); alerDialog.show(); alerDialog.setCanceledOnTouchOutside(true); Window window = alerDialog.getWindow(); // ?? int height = ScreenUtils.getScreenHeight(mContext); int width = ScreenUtils.getScreenWidth(mContext); WindowManager.LayoutParams params = window.getAttributes(); params.width = (int) (width * showWidth); params.gravity = Gravity.CENTER_HORIZONTAL; alerDialog.onWindowAttributesChanged(params); window.setContentView(layout); return alerDialog; }
From source file:de.tap.easy_xkcd.fragments.comics.ComicBrowserFragment.java
/******************* * Sharing/*from w w w. j a v a2s . co m*/ **************************/ protected boolean shareComic() { if (prefHelper.shareImage()) { shareComicImage(); return true; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setItems(R.array.share_dialog, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: shareComicImage(); break; case 1: shareComicUrl(comicMap.get(lastComicNumber)); break; } } }); AlertDialog alert = builder.create(); alert.show(); return true; }
From source file:com.df.push.DemoActivity.java
private void displayOptionsToSubscribe() { final CharSequence[] cs = topics.toArray(new CharSequence[topics.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select topic to subscribe"); builder.setItems(cs, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Do something with the selection final SharedPreferences prefs = getGcmPreferences(context); subscribe(cs[item].toString(), prefs.getString(PROPERTY_REG_URL, null)); }/*w w w .j a v a 2 s . co m*/ }); AlertDialog alert = builder.create(); alert.show(); }
From source file:amhamogus.com.daysoff.fragments.AddEventFragment.java
private boolean validate() { // Check event title exists if (summary.getText().length() < 1) { summary.setError(getResources().getString(R.string.event_form_error_summary)); return false; }/*w w w .jav a 2 s. c om*/ // Check start time proceeds end time if (start == null) { start = DateFormater.getDateTime(startTimeLabel.getText().toString(), currentDate, noonOrNight); } if (end == null) { end = DateFormater.getDateTime(endTimeLabel.getText().toString(), currentDate, noonOrNight); } Date startDate = new Date(start.getValue()); Date endDate = new Date(end.getValue()); if (startDate.after(endDate)) { AlertDialog.Builder mAlertBuilder = new AlertDialog.Builder(getActivity()).setTitle("Event time error") .setMessage("Start times must proceed end times. Pick new time.") .setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = mAlertBuilder.create(); alertDialog.show(); return false; } if ((food.isChecked() || movie.isChecked() || outdoors.isChecked()) == false) { AlertDialog.Builder mAlertBuilder = new AlertDialog.Builder(getActivity()) .setTitle("Select an activity").setMessage("You must select at least 1 activity.") .setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = mAlertBuilder.create(); alertDialog.show(); return false; } return true; }
From source file:com.df.push.DemoActivity.java
private void displayOptionsToUnbscribe() { if (subscriptions.size() == 0) { Toast.makeText(getApplicationContext(), "No Subscriptions...", Toast.LENGTH_LONG).show(); return;//from w ww . j a va2 s. c om } final CharSequence[] cs = subscriptions.toArray(new CharSequence[subscriptions.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select item to unsubscribe"); builder.setItems(cs, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Do something with the selection unsubscribe(cs[item].toString()); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error//from w w w . j av a 2s . com * @param errStr */ public void showDialogInformation(String errStr) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setIcon(R.drawable.icon); adb.setTitle(R.string.str_ErrPlay_Title); adb.setMessage(errStr); adb.setPositiveButton(R.string.str_OK, new OnClickListener() { public void onClick(DialogInterface a0, int a1) { return; } }); AlertDialog ad = adb.create(); ad.show(); }
From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java
@Override public void init(Bundle savedInstanceState) { setupLayout(R.layout.activity_gpms_login, Color.parseColor("#009688")); rollNoEditText = (EditText) findViewById(R.id.roll_no); passwordEditText = (EditText) findViewById(R.id.pwd); AlertDialog.Builder builder = new AlertDialog.Builder(baseContext); builder.setMessage("Amrita University does not provide an API for accessing GPMS data. " + "So, if any changes are made to the GPMS Website, please be patient while I try to catch up.") .setCancelable(true).setIcon(R.drawable.ic_action_info_small) .setPositiveButton("Got it !", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();/*from w w w. j a v a 2s . c o m*/ hideSoftKeyboard(); showConnectToAmritaAlert(); } }); AlertDialog alert = builder.create(); alert.requestWindowFeature(Window.FEATURE_NO_TITLE); alert.show(); dialog = new ProgressDialog(baseContext); dialog.setIndeterminate(true); dialog.setCancelable(false); dialog.setInverseBackgroundForced(false); dialog.setCanceledOnTouchOutside(false); dialog.setMessage("Authenticating your credentials ... "); preferences = getSharedPreferences("gpms_prefs", Context.MODE_PRIVATE); String rollNo = preferences.getString("roll_no", ""); String encodedPassword = preferences.getString("password", ""); if (!rollNo.equals("")) { rollNoEditText.setText(rollNo); studentRollNo = rollNo; hideSoftKeyboard(); } else { SharedPreferences aumsPrefs = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE); String aumsRollNo = aumsPrefs.getString("RollNo", ""); if (!aumsRollNo.equals("")) { rollNoEditText.setText(aumsRollNo); studentRollNo = aumsRollNo; hideSoftKeyboard(); } } if (!encodedPassword.equals("")) { passwordEditText.setText(Security.decrypt(encodedPassword, MainApplication.key)); hideSoftKeyboard(); } }
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error// w w w . j av a 2s .c om * @param errStr */ public void showDialogError(String errStr) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setIcon(R.drawable.icon); adb.setTitle(R.string.str_ErrPlay_Title); adb.setMessage(errStr); adb.setPositiveButton(R.string.str_OK, new OnClickListener() { public void onClick(DialogInterface a0, int a1) { finish(); } }); adb.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { dialog.dismiss(); finish(); return true; } return false; } }); AlertDialog ad = adb.create(); ad.show(); }