Example usage for android.widget Toast setGravity

List of usage examples for android.widget Toast setGravity

Introduction

In this page you can find the example usage for android.widget Toast setGravity.

Prototype

public void setGravity(int gravity, int xOffset, int yOffset) 

Source Link

Document

Set the location at which the notification should appear on the screen.

Usage

From source file:com.mobilevangelist.glass.helloworld.GetTheWeatherActivity.java

private Bitmap loadImageFromURL(String getURL) {

    try {//w w w  . ja  va2  s .  c  om
        URL url = new URL(getURL);

        HttpGet httpRequest = null;
        httpRequest = new HttpGet(url.toURI());
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
        HttpEntity entity = response.getEntity();
        BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
        InputStream input = b_entity.getContent();
        Bitmap bitmap = BitmapFactory.decodeStream(input);
        return bitmap;
    } catch (Exception ex) {

        Toast t2 = Toast.makeText(getApplicationContext(), "Image Loading Failed", Toast.LENGTH_LONG);
        t2.setGravity(Gravity.CENTER, 0, 0);
        t2.show();
        return null;
    }
}

From source file:com.birkettenterprise.phonelocator.activity.AuthenticationActivity.java

private void toast(int resourceId) {
    Toast toast = Toast.makeText(this, resourceId, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.TOP, 0, 0);
    toast.show();// w  w  w .j  a v  a2  s.co  m
}

From source file:org.peterbaldwin.vlcremote.fragment.BrowseFragment.java

private void showSetHomeToast() {
    Context context = getActivity();
    CharSequence message = getString(R.string.sethome, getTitle());
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//  w  w  w.  ja  v a2  s  .c o  m
}

From source file:com.radicaldynamic.groupinform.application.Collect.java

public void showCustomToast(String message) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = inflater.inflate(R.layout.toast_view, null);

    // Set the text in the view
    TextView tv = (TextView) view.findViewById(R.id.message);
    tv.setText(message);/*from  w w w  .  jav a  2s  .com*/

    Toast t = new Toast(this);
    t.setView(view);
    t.setDuration(Toast.LENGTH_SHORT);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();
}

From source file:org.sigimera.app.android.GCMIntentService.java

@Override
protected final void onUnregistered(final Context context, String regID) {
    final String HOST = Config.getInstance().getAPIHost() + "/gcm";
    HttpClient httpclient = new MyHttpClient(ApplicationController.getInstance().getApplicationContext());
    try {//from   w  ww  . j  a  v  a  2s.com
        String authToken = SessionHandler.getInstance(null).getAuthenticationToken();
        final String toastMessage;
        if (regID != null && !regID.equals("")) {
            HttpDelete request = new HttpDelete(HOST + "/" + regID + "?auth_token=" + authToken);
            httpclient.execute(request);
            toastMessage = "Successfully unregistered!";
        } else {
            toastMessage = "You are not registered to receive push notifications.";
        }
        this.mainThreadHandler.post(new Runnable() {
            public void run() {
                Toast toast = Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP, 0, 0);
                toast.show();
            }
        });
    } catch (AuthenticationErrorException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:com.secbro.qark.tapjacking.TapJackingExploitFragment.java

private Toast createToast() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Toast toast = Toast.makeText(this.getActivity(), "", Toast.LENGTH_SHORT);
    View view = inflater.inflate(R.layout.tap_jacking_toast, null);
    toast.setView(view);//from   www  .  j  av  a 2 s  . c o m
    toast.setGravity(Gravity.FILL, 0, 0);
    return toast;
}

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

@UiThread
public void showToastLong(String message) {
    Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();//from  w ww. j  av a  2 s.c  om
}

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

@UiThread
public void showToast(String message) {
    Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();/*ww  w.  jav  a2 s .  co  m*/
}

From source file:com.example.multi_ndef.frag_wifi.java

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

    try {//from  w  w  w .ja  v  a  2s .c o  m
        network_name = mSpinner.getSelectedItem().toString();
        password = mEditText1.getText().toString();
        fr.setWifiNetwork(network_name);
        fr.setWifiPassword(password);

    } catch (Exception e) {
        Toast toast = Toast.makeText(getActivity().getApplicationContext(),
                "Unable to populate available Wi-Fi networks. Please press back button and again press write",
                Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0);
        toast.show();
    }
}

From source file:com.ame.armymax.SettingsActivity.java

protected void showToast(String message) {

    Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*from  www  .j  a va2 s .c  om*/

}