List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
From source file:org.mklab.mikity.android.SampleSelectionFragment.java
/** * {@inheritDoc}/*from w ww.ja v a 2s. co m*/ */ public void onSuccessLoadSourceData(String sourceId, String fileName) { this.sourceFileNameViews.get(sourceId).setText(fileName); this.sourceFileNames.put(sourceId, fileName); final Toast toast = Toast.makeText(getActivity(), getString(R.string.loadedSuccessfully), Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER | Gravity.BOTTOM, 0, 0); toast.show(); }
From source file:com.endiansoftware.echo.remotewatch.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { /*//from w ww .j a v a 2s .co m // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); */ /* // ? ?? . Intent popupIntent = new Intent(context, Popup.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // . context.startActivity(popupIntent); */ LinearLayout layout = new LinearLayout(context); //layout.setBackgroundResource(R.color.LightOrange); TextView tv = new TextView(context); // set the TextView properties like color, size etc tv.setTextColor(Color.RED); tv.setTextSize(15); tv.setGravity(Gravity.CENTER_VERTICAL); // set the text you want to show in Toast tv.setText("My Custom Toast at Bottom of Screen"); layout.addView(tv); Toast toast = new Toast(context); //context is object of Context write "this" if you are an Activity // Set The layout as Toast View toast.setView(layout); // Position you toast here toast position is 50 dp from bottom you can give any integral value toast.setGravity(Gravity.BOTTOM, 0, 50); toast.show(); }
From source file:net.micode.fileexplorer.ServerControlActivity.java
private void warnIfNoExternalStorage() { String storageState = Environment.getExternalStorageState(); if (!storageState.equals(Environment.MEDIA_MOUNTED)) { myLog.i("Warning due to storage state " + storageState); Toast toast = Toast.makeText(mActivity, R.string.storage_warning, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();//w w w.java 2 s. c o m } }
From source file:com.hyperkode.friendshare.fragment.LoginFragment.java
private void setupButtons() { // Login button handler loginButton = (Button) mThisActivity.findViewById(R.id.loginbutton_continue); loginButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText usernameText = (EditText) mThisActivity.findViewById(R.id.login_username_textbox); String un = usernameText.getText().toString(); if (cb != null && cb.isChecked()) { // do Twitter login authTwitter();//from w w w. j a v a 2 s . co m return; } if (un == null || un.length() == 0) { Toast toast = Toast.makeText(mThis, mThis.getString(R.string.enter_username), Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0); toast.show(); return; } //EditText passwordText = (EditText) findViewById(R.id.login_password_textbox); //String pw = passwordText.getText().toString(); //Intent i = new Intent(mThis, LandingActivity.class); //mThis.startActivity(i); /* FragmentManager fm = LoginFragment.this.getActivity().getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.main_view_containter, LoginFragment.this); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); */ } }); // Cancel button handler cancelButton = (Button) mThisActivity.findViewById(R.id.loginbutton_cancel); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Exit screen mThis.finish(); } }); }
From source file:com.zerobyte.lifesync.EventDisplayActivity.java
private void showToast(String text) { Toast toast = Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.setText(text);/* www . j a v a 2s . c o m*/ toast.show(); }
From source file:com.androidquery.simplefeed.base.BaseActivity.java
public void showToast(String message) { if (message == null || message.length() == 0) return;//from w w w .j a va 2s . c o m try { Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } catch (Exception e) { AQUtility.report(e); } }
From source file:com.licubeclub.zionhs.Notices_Parents.java
private void networkTask() { final Handler mHandler = new Handler(); new Thread() { public void run() { mHandler.post(new Runnable() { public void run() { SRL.setRefreshing(true); }/* ww w . ja va2 s .co m*/ }); //Task //Notices URL try { titlearray = new ArrayList<String>(); titleherfarray = new ArrayList<String>(); authorarray = new ArrayList<String>(); datearray = new ArrayList<String>(); Document doc = Jsoup.connect( "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=59") .get(); Elements rawdata = doc.select(".listbody a"); //Get contents from tags,"a" which are in the class,"listbody" Elements rawauthordata = doc.select("td:eq(3)"); //? ? - 3 td ? Elements rawdatedata = doc.select("td:eq(4)"); // ? - 4 td ? String titlestring = rawdata.toString(); Log.i("Notices", "Parsed Strings" + titlestring); for (Element el : rawdata) { String titlherfedata = el.attr("href"); String titledata = el.attr("title"); titleherfarray.add("http://www.zion.hs.kr/" + titlherfedata); // add value to ArrayList titlearray.add(titledata); // add value to ArrayList } Log.i("Notices", "Parsed Link Array Strings" + titleherfarray); Log.i("Notices", "Parsed Array Strings" + titlearray); for (Element el : rawauthordata) { String authordata = el.text(); Log.d("Author", el.text()); authorarray.add(authordata); } for (Element el : rawdatedata) { String datedata = el.text(); Log.d("Date", el.text()); datearray.add(datedata); } } catch (IOException e) { e.printStackTrace(); } mHandler.post(new Runnable() { public void run() { //UI Task adapter = new PostListAdapter(Notices_Parents.this, titlearray, datearray, authorarray); listview.setAdapter(adapter); listview.setOnItemClickListener(GoToWebPage); handler.sendEmptyMessage(0); SRL.setRefreshing(false); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.noti_parents_info), Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 0); toast.show(); } }); } }.start(); }
From source file:org.mklab.mikity.android.SampleSelectionFragment.java
/** * {@inheritDoc}//from w w w.j a v a 2s . c o m */ public void onSuccessLoadModelData(InputStream input, String fileName) { this.modelFileName = fileName; this.modelFileNameView.setText(this.modelFileName); final String sampleSourceFileName = "..."; //$NON-NLS-1$ for (final TextView view : this.sourceFileNameViews.values()) { view.setText(sampleSourceFileName); } this.sourceFileNames.clear(); if (this.canvasFragment.sourceData.size() != 0) { this.canvasFragment.sourceData.clear(); } updateSourceComponent(); this.mainActivity.fileSelectionFragment.reset(); this.mainActivity.modelFileUri = null; final Toast toast = Toast.makeText(getActivity(), getString(R.string.loadedSuccessfully), Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER | Gravity.BOTTOM, 0, 0); toast.show(); }
From source file:com.geomoby.geodeals.DemoService.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.geomoby_main); mContext = this; mToggle = (CompoundButton) findViewById(R.id.togglebutton); spref = getSharedPreferences(PREF_NAME, MODE_PRIVATE); isCheckedStatus = spref.getBoolean("check", false); //default is false /*//from w w w. j av a2s .c om * Set up toggle status */ if (!isCheckedStatus) mToggle.setChecked(false); else mToggle.setChecked(true); /* * Save the tags in the GeoMoby shared preferences in private mode for the user. These tags will be used * to segment your audience when creating your proximity alerts. Please make sure that they match with * the ones configured in your dashboard when you create an alert. * Ex: 'test' is the default tag so make sure that it is set up in your Account page */ SharedPreferences mySharedPreferences = getSharedPreferences(PREF, MODE_PRIVATE); // Build the string of tags - empty for testing. Make sure that you create your first geofences with no tags in your dashboard. // Add your own logic here: "male,vip,monday"... String tags = ""; // Commit the string SharedPreferences.Editor prefEditor = mySharedPreferences.edit(); prefEditor.putString(SETTING_TAGS, tags); prefEditor.commit(); /* * Monitor the toggle - Our SDK will ensure that all services are running/stopping properly */ mToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked == false) { mToggle.setPressed(false); // Stop the GeoMoby tracking service startService(new Intent(DemoService.this, GeomobyStopService.class)); SharedPreferences.Editor editor = spref.edit(); editor.putBoolean("check", false); editor.commit(); } else { mToggle.setPressed(true); // Start the GeoMoby tracking service startService(new Intent(DemoService.this, GeomobyStartService.class)); SharedPreferences.Editor editor = spref.edit(); editor.putBoolean("check", true); editor.commit(); LayoutInflater inflater = getLayoutInflater(); // Inflate the Layout View layout = inflater.inflate(R.layout.geomoby_toast, (ViewGroup) findViewById(R.id.custom_toast_layout)); // Set the Text to show in TextView TextView text = (TextView) layout.findViewById(R.id.textToShow); text.setText("GREAT! YOU ARE READY TO RECEIVE REAL-TIME NOTIFICATIONS!"); Typeface face; face = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf"); text.setTypeface(face); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.BOTTOM, 0, 50); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } } }); // Initialise GeoMoby Notification Listener GeomobyNotificationsReceiver receiver = new GeomobyNotificationsReceiver(); receiver.setNotificationListener(this); }
From source file:com.royclarkson.springagram.MainActivity.java
public void onNetworkError(String message) { Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();// ww w . ja v a2 s . c o m }