List of usage examples for android.widget Toast show
public void show()
From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java
/** * Make a standard toast that just contains a text view with the text from a * resource, for long time//w ww. j ava2 s . co m * * @param str * The resource id of the string resource to use. Can be * formatted text. */ public void toast(int str) { Toast toast = Toast.makeText(this, str, Toast.LENGTH_LONG); toast.setGravity(LinearLayout.VERTICAL, 0, 0); toast.show(); }
From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java
/** * Make a standard toast that just contains a text view, for long time * * @param str/*from w ww .ja v a 2s .c om*/ * The text to show. Can be formatted text. */ public void toast(String str) { Toast toast = Toast.makeText(this, str, Toast.LENGTH_SHORT); toast.setGravity(LinearLayout.VERTICAL, 0, 0); toast.show(); }
From source file:com.anjalimacwan.fragment.NoteListFragment.java
private void showToast(int message) { Toast toast = Toast.makeText(getActivity(), getResources().getString(message), Toast.LENGTH_SHORT); toast.show(); }
From source file:edu.stanford.mobisocial.dungbeetle.SettingsActivity.java
public void toast(String msg) { Toast error = Toast.makeText(this, msg, Toast.LENGTH_SHORT); error.show(); }
From source file:com.alexlionne.apps.avatars.Utils.DirectoryChooserFragment.java
/** * Shows a confirmation dialog that asks the user if he wants to create a * new folder.//ww w.j a v a 2 s . c om */ private void openNewFolderDialog() { new AlertDialog.Builder(getActivity()).setTitle(R.string.create_folder_label) .setMessage(String.format(getString(R.string.create_folder_msg), mNewDirectoryName)) .setNegativeButton(R.string.cancel_label, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); int msg = createFolder(); Toast t = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT); t.show(); } }).create().show(); }
From source file:cm.aptoide.pt.webservices.login.Login.java
private void checkCredentials(String username, String password) { if (username.trim().length() > 0 && password.trim().length() > 0) { new CheckUserCredentials().execute(username, password, "false"); } else {/*from w ww.j ava 2 s.c o m*/ Toast toast = Toast.makeText(context, context.getString(R.string.check_your_credentials), Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 30); toast.show(); } }
From source file:com.guess.license.plate.Task.LoadingTaskConn.java
@Override protected void onPostExecute(ServerError result) { super.onPostExecute(result); loadingDialog.dismiss();//from w ww .jav a 2 s. c om if (result != null && !result.equals(ServerError.NO_ERROR)) { Toast toast = Toast.makeText(context, Language.GetServerErrorLanguage(result, context), Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); } new CountDownTimer(TIMER, 1000) { public void onTick(long millisUntilFinished) { // Do nothing } public void onFinish() { activity.onTaskFinished(); } }.start(); }
From source file:org.umit.icm.mobile.gui.ControlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.controlactivity); WebsiteSuggestButton = (Button) this.findViewById(R.id.suggestWebsite); ServiceSuggestButton = (Button) this.findViewById(R.id.suggestService); scanButton = (Button) this.findViewById(R.id.scanButton); // filterButton = (Button) this.findViewById(R.id.filterButton); // servicesFilterButton = (Button) this.findViewById(R.id.serviceFilterButton); mapSelectionButton = (Button) this.findViewById(R.id.mapSelectionButton); enableTwitterButton = (Button) this.findViewById(R.id.enableTwitterButton); bugReportButton = (Button) this.findViewById(R.id.bugReportButton); aboutButton = (Button) this.findViewById(R.id.aboutButton); scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); try {/* www . ja v a2 s. c o m*/ if (Globals.runtimeParameters.getTwitter().equals("Off")) { enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } else { enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } } catch (RuntimeException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("org.umit.icm.mobile.CONTROL_ACTIVITY")) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); } } }; registerReceiver(receiver, new IntentFilter("org.umit.icm.mobile.CONTROL_ACTIVITY")); WebsiteSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { WebsiteSuggestionDialog websiteSuggestionDialog = new WebsiteSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); websiteSuggestionDialog.show(); } }); ServiceSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { ServiceSuggestionDialog suggestionDialog = new ServiceSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); suggestionDialog.show(); } }); enableTwitterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { if (Globals.runtimeParameters.getTwitter().equals("Off")) { progressDialog = ProgressDialog.show(ControlActivity.this, getString(R.string.loading), getString(R.string.retrieving_website), true, false); new LaunchBrowser().execute(); TwitterDialog twitterDialog = new TwitterDialog(ControlActivity.this, ""); twitterDialog.show(); enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } else { Globals.runtimeParameters.setTwitter("Off"); enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mapSelectionButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { MapSelectionDialog MapSelectionDialog = new MapSelectionDialog(ControlActivity.this, ""); MapSelectionDialog.show(); } }); /* filterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, WebsiteFilterActivity.class); startActivity(intent); } } ); servicesFilterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, ServiceFilterActivity.class); startActivity(intent); } } );*/ bugReportButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, BugReportActivity.class); startActivity(intent); } }); aboutButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String msg = getString(R.string.about_text) + "\n" + getString(R.string.link_to_open_monitor) + "\n" + getString(R.string.link_to_umit) + "\n" + getString(R.string.icons_by); final SpannableString spannableString = new SpannableString(msg); Linkify.addLinks(spannableString, Linkify.ALL); AlertDialog alertDialog = new AlertDialog.Builder(ControlActivity.this).create(); alertDialog.setTitle(getString(R.string.about_button)); alertDialog.setMessage(spannableString); alertDialog.setIcon(R.drawable.umit_128); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } }); scanButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (Globals.scanStatus.equalsIgnoreCase(getString(R.string.scan_on))) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); Globals.scanStatus = getString(R.string.scan_off); stopService(new Intent(ControlActivity.this, ConnectivityService.class)); } else { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); Globals.scanStatus = getString(R.string.scan_on); startService(new Intent(ControlActivity.this, ConnectivityService.class)); } try { Globals.runtimeParameters.setScanStatus(Globals.scanStatus); } catch (RuntimeException e) { e.printStackTrace(); } Context context = getApplicationContext(); CharSequence text = getString(R.string.toast_scan_change) + " " + Globals.scanStatus; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }); }
From source file:com.tmm.android.facebook.HelloFacebookSampleActivity.java
private void showPickerFragment(PickerFragment<?> fragment) { fragment.setOnErrorListener(new PickerFragment.OnErrorListener() { @Override// ww w .j a va 2s.c om public void onError(PickerFragment<?> pickerFragment, FacebookException error) { String text = getString(R.string.exception, error.getMessage()); Toast toast = Toast.makeText(HelloFacebookSampleActivity.this, text, Toast.LENGTH_SHORT); toast.show(); } }); FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction().replace(R.id.fragment_container, fragment).addToBackStack(null).commit(); controlsContainer.setVisibility(View.GONE); // We want the fragment fully created so we can use it immediately. fm.executePendingTransactions(); fragment.loadData(false); }
From source file:com.facebook.android.MainPage.java
/** Called when the activity is first created. */ @Override/*from ww w . j a v a2 s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see Example.java"); } setContentView(R.layout.main); mMovieNameInput = (EditText) findViewById(R.id.title); mMediaSpinner = (Spinner) findViewById(R.id.media); mSearchButton = (Button) findViewById(R.id.search); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionStore.restore(mFacebook, this); SessionEvents.addAuthListener(new SampleAuthListener()); SessionEvents.addLogoutListener(new SampleLogoutListener()); // set up the Spinner for the media list selection ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.media_list, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mMediaSpinner.setAdapter(adapter); //for search button final Context context = this; mSearchButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String servletURL; String movieName = mMovieNameInput.getText().toString(); // check the input text of movie, if the text is empty give user alert movieName = movieName.trim(); if (movieName.length() == 0) { Toast toast = Toast.makeText(context, "Please enter a movie name", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 70); toast.show(); } // if movie name is not empty else { // remove any extra whitespace movieName = movieName.replaceAll("\\s+", "+"); String mediaList = mMediaSpinner.getSelectedItem().toString(); if (mediaList.equals("Feature Film")) { mediaList = "feature"; } mediaList = mediaList.replaceAll("\\s+", "+"); // construct the query string // construct the final URL to Servlet //String servletString = "?" + "title=" + movieName + "&" + "title_type=" + mediaList; //servletURL = "http://cs-server.usc.edu:10854/examples/servlet/Amovie" //+ servletString; //String servletString = "?" + "title=" + movieName + "&" + "media=" + mediaList; //servletURL = "http://cs-server.usc.edu:34404/examples/servlet/HelloWorldExample?title=" + movieName + "&" + "media=" + mediaList; //+ servletString; servletURL = "http://cs-server.usc.edu:10854/examples/servlet/Amovie?title=" + movieName + "&" + "title_type=" + mediaList; BufferedReader in = null; try { // REFERENCE: this part of code is modified from: // "Example of HTTP GET Request using HttpClient in Android" // http://w3mentor.com/learn/java/android-development/android-http-services/example-of-http-get-request-using-httpclient-in-android/ // get response (JSON string) from Servlet HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI(servletURL)); HttpResponse response = client.execute(request); in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String page = sb.toString(); //test for JSON string /*LinearLayout lView = new LinearLayout(context); TextView myText = new TextView(context); myText.setText(page); lView.addView(myText); setContentView(lView);*/ // convert the JSON string to real JSON and get out the movie JSON array // to check if there is any movie data JSONObject finalJson; JSONObject movieJson; JSONArray movieJsonArray; finalJson = new JSONObject(page); movieJson = finalJson.getJSONObject("results"); //System.out.println(movieJson); movieJsonArray = movieJson.getJSONArray("result"); // if the response contains some movie data if (movieJsonArray.length() != 0) { // start the ListView activity, and pass the JSON string to it Intent intent = new Intent(context, MovieListActivity.class); intent.putExtra("finalJson", page); startActivity(intent); } // if the response does not contain any movie data, // show user that there is no result for this search else { Toast toast = Toast.makeText(getBaseContext(), "No movie found for this search", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } } catch (URISyntaxException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } } }); }