Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:net.networksaremadeofstring.cyllell.ViewEnvironments_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list = (ListView) this.getActivity().findViewById(R.id.environmentsListView);
    settings = this.getActivity().getSharedPreferences("Cyllell", 0);
    try {/*from  w  w w . j a v a 2  s .co  m*/
        Cut = new Cuts(getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }

    dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Contacting Chef");
    dialog.setMessage("Please wait: Prepping Authentication protocols");
    dialog.setIndeterminate(true);
    if (listOfEnvironments.size() < 1) {
        dialog.show();
    }

    updateListNotify = new Handler() {
        public void handleMessage(Message msg) {
            int tag = msg.getData().getInt("tag", 999999);

            if (msg.what == 0) {
                if (tag != 999999) {
                    listOfEnvironments.get(tag).SetSpinnerVisible();
                }
            } else if (msg.what == 1) {
                //Get rid of the lock
                CutInProgress = false;

                //the notifyDataSetChanged() will handle the rest
            } else if (msg.what == 99) {
                if (tag != 999999) {
                    Toast.makeText(ViewEnvironments_Fragment.this.getActivity(),
                            "An error occured during that operation.", Toast.LENGTH_LONG).show();
                    listOfEnvironments.get(tag).SetErrorState();
                }
            }
            EnvironmentAdapter.notifyDataSetChanged();
        }
    };

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            //Once we've checked the data is good to use start processing it
            if (msg.what == 0) {
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        //Log.i("OnClick","Clicked");
                        GetMoreDetails((Integer) v.getTag());
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        selectForCAB((Integer) v.getTag());
                        return true;
                    }
                };

                EnvironmentAdapter = new EnvironmentListAdaptor(getActivity().getBaseContext(),
                        listOfEnvironments, listener, listenerLong);
                list = (ListView) getView().findViewById(R.id.environmentsListView);
                if (list != null) {
                    if (EnvironmentAdapter != null) {
                        list.setAdapter(EnvironmentAdapter);
                    } else {
                        //Log.e("EnvironmentAdapter","EnvironmentAdapter is null");
                    }
                } else {
                    //Log.e("List","List is null");
                }

                dialog.dismiss();
            } else if (msg.what == 200) {
                dialog.setMessage("Sending request to Chef...");
            } else if (msg.what == 201) {
                dialog.setMessage("Parsing JSON.....");
            } else if (msg.what == 202) {
                dialog.setMessage("Populating UI!");
            } else {
                //Close the Progress dialog
                dialog.dismiss();

                //Alert the user that something went terribly wrong
                AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
                alertDialog.setTitle("API Error");
                alertDialog.setMessage("There was an error communicating with the API:\n"
                        + msg.getData().getString("exception"));
                alertDialog.setButton2("Back", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        getActivity().finish();
                    }
                });
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            if (listOfEnvironments.size() > 0) {
                handler.sendEmptyMessage(0);
            } else {
                try {
                    handler.sendEmptyMessage(200);
                    Environments = Cut.GetEnvironments();
                    handler.sendEmptyMessage(201);

                    JSONArray Keys = Environments.names();

                    for (int i = 0; i < Keys.length(); i++) {
                        listOfEnvironments.add(
                                new Environment(Keys.getString(i), Environments.getString(Keys.getString(i))
                                        .replaceFirst("^(https://|http://).*/environments/", "")));
                    }

                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
            }
            return;
        }
    };

    dataPreload.start();
    return inflater.inflate(R.layout.environments_landing, container, false);
}

From source file:com.csipsimple.ui.calllog.CallLogListFragment.java

private void deleteAllCalls() {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle(R.string.callLog_delDialog_title);
    alertDialog.setMessage(getString(R.string.callLog_delDialog_message));
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.callLog_delDialog_yes),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null, null);
                }//ww w.  j a v a2  s.  co  m
            });
    alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.callLog_delDialog_no),
            (DialogInterface.OnClickListener) null);
    try {
        alertDialog.show();
    } catch (Exception e) {
        Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog");
    }
}

From source file:com.swetha.easypark.DisplayVacantParkingLots.java

@SuppressWarnings("deprecation")
public void updatemap(ArrayList<HashMap<String, String>> alofHashmap, int Success) {

    if (success == 1) {
        try {//from  www . j  a v  a2  s.  c o m
            googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.parkinglotsmap))
                    .getMap();
            IconGenerator ig = new IconGenerator(this);

            googleMap.clear();
            for (int i = (alofHashmap.size() - 1); i >= 0; i--) {
                //canvas.drawText(alofHashmap.get(i).get("costForParking"), 0, 40, paint);
                LatLng latLng = new LatLng(Double.parseDouble(alofHashmap.get(i).get("latitude")),
                        Double.parseDouble(alofHashmap.get(i).get("longitude")));
                Bitmap bmp = ig.makeIcon(alofHashmap.get(i).get("costForParking"));
                googleMap.addMarker(new MarkerOptions().position(latLng)
                        //.title()
                        //.snippet(alofHashmap.get(i).get("lotsInfoTextView"))
                        .icon(BitmapDescriptorFactory.fromBitmap(bmp))).showInfoWindow();
                //.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_car))).showInfoWindow();
                googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
                googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
            }

            googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker arg0) {
                    LatLng markerLatLng = arg0.getPosition();
                    Log.i("DisplayVacantParkingLots",
                            "Value of the marker that was clicked is" + markerLatLng.toString());
                    for (int i = (parkingLotsMapList.size() - 1); i >= 0; i--) {
                        Log.i("DisplayVacantParkingLots", "value in the parkinglots map inside for loop"
                                + parkingLotsMapList.get(i).toString());
                        if (parkingLotsMapList.get(i).containsValue(String.valueOf(markerLatLng.latitude))
                                && parkingLotsMapList.get(i)
                                        .containsValue(String.valueOf(markerLatLng.longitude))) {
                            Intent intent = new Intent(DisplayVacantParkingLots.this,
                                    GetIndividualParkingSpotDetails.class);
                            intent.putExtra("individualParkingLotId",
                                    parkingLotsMapList.get(i).get("vacantParkingLotId"));
                            Log.i("DisplayVacantParkingLots",
                                    "The value of the parkinglot of the marker clicked is"
                                            + parkingLotsMapList.get(i).get("vacantParkingLotId"));
                            intent.putExtra(GetParkingLots.FROMTIME, DisplayVacantParkingLots.fromTime);
                            intent.putExtra(GetParkingLots.TOTIME, DisplayVacantParkingLots.toTime);
                            startActivity(intent);
                        }
                    }
                    return true;
                }

            });
        } catch (Exception e) {

        } finally {

        }
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(DisplayVacantParkingLots.this).create();

        alertDialog.setTitle("Sorry!");

        alertDialog.setMessage("No parking lots found");

        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // Write your code here to execute after dialog closed
                Intent intent = new Intent(DisplayVacantParkingLots.this, GetParkingLots.class);
                startActivity(intent);
            }
        });

        alertDialog.show();

    }
}

From source file:in.animeshpathak.nextbus.NextBusMain.java

/**
 * Creates the Application Info dialog with clickable links.
 * //from  w  ww  . j  av a  2 s .  c  o  m
 * @throws UnsupportedEncodingException
 * @throws IOException
 */
private void showVersionInfoDialog() throws UnsupportedEncodingException, IOException {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(getString(R.string.app_name) + " " + getString(R.string.version_name));

    AssetManager assetManager = getResources().getAssets();
    String versionInfoFile = getString(R.string.versioninfo_asset);
    InputStreamReader reader = new InputStreamReader(assetManager.open(versionInfoFile), "UTF-8");
    BufferedReader br = new BufferedReader(reader);
    StringBuffer sbuf = new StringBuffer();
    String line;
    while ((line = br.readLine()) != null) {
        sbuf.append(line);
        sbuf.append("\r\n");
    }

    final ScrollView scroll = new ScrollView(this);
    final TextView message = new TextView(this);
    final SpannableString sWlinks = new SpannableString(sbuf.toString());
    Linkify.addLinks(sWlinks, Linkify.WEB_URLS);
    message.setText(sWlinks);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setPadding(15, 15, 15, 15);
    scroll.addView(message);
    alertDialog.setView(scroll);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // nothing to do, just dismiss dialog
        }
    });
    alertDialog.show();
}

From source file:com.workingagenda.democracydroid.Adapters.ViewHolders.EpisodeViewHolder.java

@RequiresApi(api = Build.VERSION_CODES.M)
@Override/*from w ww. j a  v  a 2s.  c o m*/
public boolean onMenuItemClick(MenuItem menuItem) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
    int DEFAULT_STREAM = Integer.parseInt(preferences.getString("stream_preference", "0")); // 0=video
    int DEFAULT_OPEN = Integer.parseInt(preferences.getString("open_preference", "0")); // 0 = within this ap
    String actionTitle = "Democracy Now!";
    if (mEpisode.getTitle().length() > 16) {
        if ("Today's Broadcast".equals(mEpisode.getTitle())) {
            actionTitle = mEpisode.getTitle();
        } else if (mEpisode.getTitle().startsWith("Democracy Now!")) {
            actionTitle = mEpisode.getTitle().substring(14);
        } else {
            actionTitle = mEpisode.getTitle();
        }
    }

    switch (menuItem.getItemId()) {
    case R.id.action_share:
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, mEpisode.getTitle());
        sendIntent.putExtra(Intent.EXTRA_TEXT, mEpisode.getUrl());
        sendIntent.setType("text/plain");
        itemView.getContext().startActivity(sendIntent);
        return true;
    case R.id.reverse_default_media:
        if (mEpisode.getVideoUrl().contains("m3u8"))
            startMediaIntent(mEpisode.getAudioUrl(), 1, mEpisode.getTitle());
        else if (DEFAULT_STREAM == 0)
            startMediaIntent(mEpisode.getAudioUrl(), DEFAULT_OPEN, actionTitle);
        else
            startMediaIntent(mEpisode.getVideoUrl(), DEFAULT_OPEN, actionTitle);
        return true;
    case R.id.reverse_default_open:
        int reverseOpen = 0;
        if (reverseOpen == DEFAULT_OPEN)
            reverseOpen = 1;
        if (DEFAULT_STREAM == 0)
            startMediaIntent(mEpisode.getVideoUrl(), reverseOpen, actionTitle);
        else
            startMediaIntent(mEpisode.getAudioUrl(), reverseOpen, actionTitle);
        return true;
    case R.id.action_description:
        AlertDialog description = new AlertDialog.Builder(itemView.getContext()).create();
        // Get Description and Title
        description.setTitle("The War and Peace Report");
        description.setMessage(mEpisode.getDescription() + "\n\n" + mEpisode.getTitle());
        description.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // do nothing
            }
        });
        description.show();
        return true;
    case R.id.video_download:
        if (mEpisode.getTitle().equals("Stream Live"))
            return true;
        Download(mEpisode.getVideoUrl(), mEpisode.getTitle(), mEpisode.getDescription());
        return true;
    case R.id.audio_download:
        if (mEpisode.getTitle().equals("Stream Live"))
            return true;
        Download(mEpisode.getAudioUrl(), mEpisode.getTitle(), mEpisode.getDescription());
        return true;
    case R.id.open_browser:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(mEpisode.getUrl()), "*/*");
        itemView.getContext().startActivity(intent);
        return true;
    }
    return false;
}

From source file:com.kobi.metalsexchange.app.DetailFragment.java

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

    Bundle arguments = getArguments();//from w w  w. ja va2s . c  om
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
    }

    View.OnTouchListener touchListner = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            ((FABHideable) getActivity()).showFloatingActionButton();
            return false;
        }
    };

    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
    mIconView.setOnTouchListener(touchListner);

    mFriendlyDateView = (TextView) rootView.findViewById(R.id.detail_day_textview);
    mRateView = (TextView) rootView.findViewById(R.id.detail_rate_textview);
    mRateView.setOnTouchListener(touchListner);
    mRateUnitView = (TextView) rootView.findViewById(R.id.detail_rate_unit_textview);

    //mDeltaView = (TextView) rootView.findViewById(R.id.detail_delta_textview);
    mCurrency1View = (TextView) rootView.findViewById(R.id.detail_currency1_textview);
    mCurrency2View = (TextView) rootView.findViewById(R.id.detail_currency2_textview);
    mCurrency3View = (TextView) rootView.findViewById(R.id.detail_currency3_textview);

    mShekelButtonView = (ImageButton) rootView.findViewById(R.id.detail_shekel_button);
    mShekelButtonView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); //Read Update
            alertDialog.setTitle(getString(R.string.zecher_machatzit_hashekel));

            double zecherMachatzitHashekelRaw = oneGramPrice * 10;
            zecherMachatzitHashekelRaw = (double) Math.round(zecherMachatzitHashekelRaw);
            String zecherMachatzitHashekel = Utility.getFormattedCurrency(zecherMachatzitHashekelRaw,
                    Utility.getPreferredCurrency(getActivity()), getActivity(), false);

            String message = getString(R.string.zecher_machatzit_hashekel_details, zecherMachatzitHashekel);
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(R.string.zecher_machatzit_hashekel).setIcon(R.drawable.shekel).setMessage(message)
                    .setCancelable(true).setNegativeButton(R.string.about_zecher_machatzit_hashekel,
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    String url = "http://he.wikipedia.org/wiki/%D7%9E%D7%97%D7%A6%D7%99%D7%AA_%D7%94%D7%A9%D7%A7%D7%9C";
                                    Intent i = new Intent(Intent.ACTION_VIEW);
                                    i.setData(Uri.parse(url));
                                    startActivity(i);
                                    dialog.dismiss();
                                }
                            });

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

    mPidionButtonView = (ImageButton) rootView.findViewById(R.id.detail_pidion_button);
    mPidionButtonView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            double pidionHabenRaw = oneGramPrice * 100;
            pidionHabenRaw = (double) Math.round(pidionHabenRaw);
            String pidionHaben = Utility.getFormattedCurrency(pidionHabenRaw,
                    Utility.getPreferredCurrency(getActivity()), getActivity(), false);

            String message = getString(R.string.pidyon_haben_details, pidionHaben);
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(R.string.pidyon_haben).setIcon(R.drawable.ben).setMessage(message)
                    .setCancelable(true)
                    .setNegativeButton(R.string.about_pidyon_haben, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            String url = "http://he.wikipedia.org/wiki/%D7%A4%D7%93%D7%99%D7%95%D7%9F_%D7%94%D7%91%D7%9F";
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setData(Uri.parse(url));
                            startActivity(i);
                            dialog.dismiss();
                        }
                    });

            AlertDialog welcomeAlert = builder.create();
            welcomeAlert.show();
        }
    });
    return rootView;
}

From source file:devza.app.android.droidnetkey.FirewallAction.java

@Override
protected void onPostExecute(Integer result) {
    /*INVALID_CREDENTIALS = -1;
    TIMED_OUT = -2;//from ww  w  .  jav  a2s . co m
    GENERAL_ERROR = -3;*/
    if (!refresh) {
        d.dismiss();

        if (result < 0) {
            AlertDialog error = new AlertDialog.Builder(this.context).create();
            error.setTitle("Error");
            error.setButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface d, int id) {
                    d.cancel();
                }
            });

            String msg;

            switch (result) {
            case INVALID_CREDENTIALS:
                msg = "Invalid Username or Password";
                break;
            case TIMED_OUT:
                msg = "Connection Timed Out. Is your device connected to the internet?";
                break;
            case UNKNOWN_HOST:
                msg = "Could not connect. Is your device connected to the internet?";
                break;
            case GENERAL_ERROR:
                msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za";
                break;
            default:
                msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za";
                break;
            }
            error.setMessage(msg);
            error.show();
        } else {
            if (result == CONNECTED) {
                Intent usage = new Intent(this.context, UsageActivity.class);
                this.context.startActivity(usage);
                this.s.showNotification(true);
                this.s.startTimer();
            } else {
                Intent main = new Intent(this.context, MainActivity.class);
                this.context.startActivity(main);
                this.s.showNotification(false);
            }
        }
    }
}

From source file:sssemil.com.hostsaway.ui.BlacklistFragment.java

/**
 * Add new entry based on input/*ww  w . j ava2  s  .c o m*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidHostname(input)) {
            ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:sssemil.com.hostsaway.ui.WhitelistFragment.java

/**
 * Add new entry based on input/*from  w  w w.jav  a2  s.  c  om*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidWhitelistHostname(input)) {
            ProviderHelper.insertWhitelistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adaway.ui.BlacklistFragment.java

/**
 * Add new entry based on input//  w  w w  .  ja  v  a2  s  .  c o  m
 * 
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidHostname(input)) {
            ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}