Example usage for android.app AlertDialog.Builder setMessage

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

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.spoiledmilk.ibikecph.map.MapActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == ProfileActivity.RESULT_USER_DELETED) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(IbikeApplication.getString("account_deleted"));
        builder.setPositiveButton(IbikeApplication.getString("close"), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();//from  ww w .  j  a  va 2s  . c o m
            }
        });
        dialog = builder.create();
        dialog.show();
    } else if (resultCode == SearchActivity.RESULT_SEARCH_ROUTE) {
        if (data != null) {
            Bundle extras = data.getExtras();
            Location start = Util.locationFromCoordinates(extras.getDouble("startLat"),
                    extras.getDouble("startLng"));
            Location endLocation = Util.locationFromCoordinates(extras.getDouble("endLat"),
                    extras.getDouble("endLng"));
            if (extras.containsKey("fromName"))
                source = extras.getString("fromName");
            else
                source = IbikeApplication.getString("current_position");
            if (extras.containsKey("toName"))
                destination = extras.getString("toName");
            else
                destination = "";
            new SMHttpRequest().getRoute(start, endLocation, null, MapActivity.this);
        }
    } else if (resultCode == SearchAutocompleteActivity.RESULT_AUTOTOCMPLETE_SET) {
        try {
            ((AddFavoriteFragment) getSupportFragmentManager().findFragmentById(R.id.leftContainer))
                    .onActivityResult(requestCode, resultCode, data);
        } catch (Exception e) {
            try {
                ((EditFavoriteFragment) getSupportFragmentManager().findFragmentById(R.id.leftContainer))
                        .onActivityResult(requestCode, resultCode, data);
            } catch (Exception ex) {
            }
        }
    } else if (resultCode == RESULT_RETURN_FROM_NAVIGATION) {
        btnSaveFavorite.setImageResource(R.drawable.drop_pin_selector);
        pinInfoLayout.setVisibility(View.GONE);
        mapFragment.pinView.setVisibility(View.GONE);
        if (mapFragment.pinB != null) {
            mapFragment.mapView.getOverlayManager().remove(mapFragment.pinB);
        }
        if (data != null && data.getExtras() != null && data.getExtras().containsKey("overlaysShown")) {
            refreshOverlays(data.getIntExtra("overlaysShown", 0));
        }
    }
}

From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java

private void deleteCardSet(final int listItemPosition) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setMessage(R.string.delete_card_set_dialog_message);
    builder.setCancelable(false);//from w ww.  ja  va  2s. co  m
    builder.setPositiveButton(R.string.delete_card_set_dialog_ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            CardSet cardSet = mCardSets.get(listItemPosition);
            List<CardSet> cardSets = mDataSource.getCardSets();

            if (cardSets.contains(cardSet)) {

                mDataSource.deleteCardSet(cardSet);
            }

            mCardSets.remove(listItemPosition);
            Collections.sort(mCardSets);
            mArrayAdapter.notifyDataSetChanged();
        }
    });

    builder.setNegativeButton(R.string.delete_card_set_dialog_cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            dialog.cancel();
        }
    });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java

private void submit() {
    final String sched_time = format_time(mData.sched_time);
    final String depart_time = format_time(mData.depart_time);
    final String arrival_time = format_time(mData.arrival_time);
    final String agent = ((AutoCompleteTextView) findViewById(R.id.agent_entry)).getText().toString();
    final String operator = ((AutoCompleteTextView) findViewById(R.id.operator_entry)).getText().toString();
    final String from_station = ((AutoCompleteTextView) findViewById(R.id.from_station_entry)).getText()
            .toString();/*from   w w w .java2 s  .  c  o  m*/
    final String to_station = ((AutoCompleteTextView) findViewById(R.id.to_station_entry)).getText().toString();
    final String safety = Integer.toString((int) ((RatingBar) findViewById(R.id.safety_bar)).getRating());
    final String comfort = Integer.toString((int) ((RatingBar) findViewById(R.id.comfort_bar)).getRating());
    final String overall = Integer.toString((int) ((RatingBar) findViewById(R.id.overall_bar)).getRating());
    final String comment = ((EditText) findViewById(R.id.comment_entry)).getText().toString();

    String disp_sched = DateFormat.getTimeFormat(getApplicationContext()).format(mData.sched_time.getTime());
    String trip_time = format_time(
            (mData.arrival_time.getTimeInMillis() - mData.sched_time.getTimeInMillis()) / 1000);
    String delay = format_time_min(
            (mData.depart_time.getTimeInMillis() - mData.sched_time.getTimeInMillis()) / 1000);
    String info = getResources().getString(R.string.sched_time) + ": " + disp_sched + "\n"
            + getResources().getString(R.string.trip_time) + ": " + trip_time + "\n"
            + getResources().getString(R.string.delay) + ": " + delay;

    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(R.string.confirm_submit);
    alert.setMessage(info);
    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String msg = format_email(agent, operator, from_station, to_station, sched_time, depart_time,
                    arrival_time, safety, comfort, overall, comment);

            new PostTask(getApplicationContext(), msg).execute();
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alert.show();
}

From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java

 protected void DoubtBox1 () {
   // TODO Auto-generated method stub

   dialogDoubt1 = new Dialog(MainActivity_Reciever.this);
   dialogDoubt1.requestWindowFeature(Window.FEATURE_NO_TITLE);
   dialogDoubt1.setContentView(R.layout.activity_doubtlist_reciever);  //here

   mainListView = (ListView)dialogDoubt1.findViewById(R.id.mainListView);


   //list ki shuruat




   /*String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
         "Jupiter", "Saturn", "Uranus", "Neptune"};
   planetList.addAll( Arrays.asList(planets) );*/

   // Create ArrayAdapter using the planet list.
   listAdapter = new ArrayAdapter<String>(MainActivity_Reciever.this, R.layout.simplerow_reciever, planetList);
   mainListView.setAdapter(listAdapter);

   mainListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
      public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                              final int pos, long id) {
         // TODO Auto-generated method stub
         itemValue = (String) mainListView.getItemAtPosition(pos);
         DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override//from  ww  w  . jav a 2  s.  com
            public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                  case DialogInterface.BUTTON_POSITIVE:

                     new delete().execute();
                     break;

                  case DialogInterface.BUTTON_NEGATIVE:
                     //No button clicked
                     break;
               }
            }
         };

         AlertDialog.Builder builder = new AlertDialog.Builder(arg1.getContext());
         builder.setMessage("Are you sure to delete this doubt ?").setPositiveButton("Yes", dialogClickListener)
               .setNegativeButton("No", dialogClickListener).show();

         return true;

      }
   });




   dialogDoubt1.show();

}

From source file:com.autburst.picture.MainActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    final Context mContext = this;

    switch (id) {

    case DIALOG_CREATE_ALBUM_ID:

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle(R.string.new_gallery);

        View view = getLayoutInflater().inflate(R.layout.create_album, null);
        final EditText edit = (EditText) view.findViewById(R.id.albumNameEditText);
        final RadioGroup rg = (RadioGroup) view.findViewById(R.id.formatRadioGroup);

        builder2.setView(view);/*w  w w .  ja  v a2  s  .  c o m*/

        builder2.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {

                String name = edit.getText().toString();
                Log.d(TAG, "Entered name: " + name);

                // base64 encode string
                String encodedName = new String(Base64.encodeBase64(name.getBytes()));
                Log.d(TAG, "base64 encoded name: " + encodedName);

                // check if album with the same name already exist
                if (Utilities.existsAlbumName(encodedName)) {
                    // fehler
                    showDialog(DIALOG_ALBUM_NAME_ALREADY_EXIST);
                    return;
                }

                // create folder
                Utilities.getAlbumDirectory(encodedName);

                // get format
                int checkedRadioButtonId = rg.getCheckedRadioButtonId();
                final Boolean portrait;
                if (checkedRadioButtonId == R.id.portraitRB)
                    portrait = true;
                else
                    portrait = false;

                SharedPreferences settings = getSharedPreferences(Utilities.PIC_STORE, 0);
                Editor edit2 = settings.edit();
                edit2.putBoolean(encodedName + ".portrait", portrait);
                edit2.putFloat(encodedName + ".frameRate", Utilities.MEDIUM_FRAME_RATE);
                edit2.commit();
                Log.d(TAG, "portrait: " + portrait + " settingsname: " + encodedName + ".portrait frameRate: "
                        + Utilities.MEDIUM_FRAME_RATE);

                // reset editView
                edit.setText("");

                // update table
                adapter.add(encodedName);
                adapter.sort(Utilities.getAlbumNameComparator());
                adapter.notifyDataSetChanged();

                dialog.dismiss();

                controller.transformGUI(MainActivityController.CREATED_ALBUM);
            }
        });
        builder2.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
                // reset editView
                edit.setText("");
                // showDialog(DIALOG_CREATE_ALBUM_ID);
            }
        });

        AlertDialog create = builder2.create();
        dialog = create;

        break;
    case DIALOG_ALBUM_NAME_ALREADY_EXIST:
        AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
        builder3.setTitle(R.string.warning);
        builder3.setMessage(R.string.gallery_exists);
        builder3.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // dialog.dismiss();
                showDialog(DIALOG_CREATE_ALBUM_ID);
            }
        });

        dialog = builder3.create();
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java

protected void translate(final ParcelableStatus status) {
    ThreadPolicy tp = ThreadPolicy.LAX;
    StrictMode.setThreadPolicy(tp);// w w w . j a  v a 2 s  . com

    String language = Locale.getDefault().getLanguage();
    String url = "http://api.microsofttranslator.com/v2/Http.svc/Translate?contentType="
            + URLEncoder.encode("text/plain") + "&appId=" + BING_TRANSLATE_API_KEY + "&from=&to=" + language
            + "&text=";
    url = url + URLEncoder.encode(status.text_plain);
    try {
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = httpClient.execute(new HttpGet(url));

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
        String sResponse;
        StringBuilder s = new StringBuilder();

        while ((sResponse = reader.readLine()) != null) {
            s = s.append(sResponse);
        }
        String finalString = s.toString();
        finalString = finalString
                .replace("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">", "");
        finalString = finalString.replace("</string>", "");

        AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
        builder.setTitle(getString(R.string.translate));
        builder.setMessage(finalString);
        builder.setCancelable(true);
        builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });

        AlertDialog alert = builder.create();
        alert.show();

        //Toast.makeText(getActivity(), finalString, Toast.LENGTH_LONG).show();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.jesjimher.bicipalma.MesProperesActivity.java

/**
 * //from w  w w .j  av a 2  s  .  c o m
 */
private void mostrarEstadisticas() {
    int bTot = 0;
    int bAver = 0;
    int aAver = 0;
    int bLib = 0;
    int aLib = 0;
    int noBicis = 0;

    for (Estacion e : estaciones) {
        bTot += e.getAnclajesAveriados() + e.getAnclajesLibres() + e.getAnclajesUsados();
        bAver += e.getBicisAveriadas();
        aAver += e.getAnclajesAveriados();
        bLib += e.getBicisLibres();
        aLib += e.getAnclajesLibres();
        if (e.getBicisLibres() == 0)
            noBicis++;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // Si el n de bicis es negativo, es q an no se han descargado los datos
    if (bLib < 0) {
        builder.setMessage(R.string.sinDescargaTodavia).setCancelable(true).setPositiveButton(R.string.cerrar,
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    } else {
        String mensBicis = String.format(getString(R.string.estadisticasBicis), bLib, bAver);
        String mensAnclajes = String.format(getString(R.string.estadisticasAnclajes), bTot,
                bTot - (aLib + aAver), 100 * (1 - aLib / (0.0 + bTot - aAver)), aLib,
                100 * aLib / (0.0 + bTot - aAver), aAver, 100 * aAver / Double.valueOf(bTot));

        String mensVacias = String.format(getString(R.string.estadisticasVacias), noBicis, estaciones.size());

        builder.setMessage(mensBicis + mensAnclajes + mensVacias).setTitle(R.string.estadoservicio)
                .setCancelable(true).setPositiveButton(R.string.cerrar, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog assignConfirmDialog(Context context, String str, boolean startNewWeek) {

    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.remove_id, null);
    final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local);
    rm_check.setText(R.string.assign_new_week);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (startNewWeek) {
        builder.setView(textEntryView);//from   ww  w .j a v  a 2  s.co m
    }
    builder.setCancelable(false);
    builder.setTitle(R.string.assign_confirm_title);
    builder.setMessage(str);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            editor.putString(Utilities.SP_KEY_LOGIN_USERID, asID.getText().toString());
            Log.d("here!!!", "id is " + asID.getText().toString());
            //format check

            editor.putString(Utilities.SP_KEY_LOGIN_USERPWD, "");
            editor.putString(Utilities.SP_KEY_LOGIN_STUDY_STARTTIME,
                    "" + Calendar.getInstance().getTimeInMillis());
            editor.commit();

            //start new study week, if checked
            if (rm_check.isChecked()) {

                String UID = null;
                try {
                    UID = Utilities.encryption(asID.getText().toString());
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                ChangeStudyWeek changeStudyWeek = new ChangeStudyWeek();
                changeStudyWeek.execute(UID);
            }

            setHints();
            //continue with set user pin (8)
            setResult(Activity.RESULT_OK);
            finish();
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            setHints();
        }
    });
    return builder.create();
}

From source file:com.bringcommunications.etherpay.SendActivity.java

private void dsp_txid_and_exit() {
    /*/*ww  w  .  j  ava 2  s . c o m*/
    TextView txid_view = (TextView) findViewById(R.id.txid);
    txid_view.setText(txid);
    if (auto_pay.equals("true")) {
      String msg = txid.isEmpty() ? "transaction failed" : "your transaction was sent successfully";
      Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
      NavUtils.navigateUpFromSameTask(context);
      this.finish();
    } else
    */
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        String title = txid.isEmpty() ? "Error" : "Transaction Sent";
        String msg = txid.isEmpty()
                ? "An error occurred while attempting this transaction -- press OK to continue"
                : "your transaction was sent successfully -- press OK to continue";
        builder.setTitle(title);
        builder.setMessage(msg);
        builder.setCancelable(true);
        builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
                NavUtils.navigateUpFromSameTask(context);
                context.finish();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}