当前位置: 首页>>代码示例>>Java>>正文


Java Toast.show方法代码示例

本文整理汇总了Java中android.widget.Toast.show方法的典型用法代码示例。如果您正苦于以下问题:Java Toast.show方法的具体用法?Java Toast.show怎么用?Java Toast.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Toast的用法示例。


在下文中一共展示了Toast.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLongClick

import android.widget.Toast; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
  final int[] screenPos = new int[2];
  getLocationOnScreen(screenPos);

  final Context context = getContext();
  final int width = getWidth();
  final int height = getHeight();
  final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;

  Toast cheatSheet = Toast.makeText(context, mTab.getContentDescription(),
									Toast.LENGTH_SHORT);
  // Show under the tab
  cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
						(screenPos[0] + width / 2) - screenWidth / 2, height);

  cheatSheet.show();
  return true;
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:20,代码来源:TabLayout.java

示例2: show

import android.widget.Toast; //导入方法依赖的package包/类
public void show() {
    final Toast toast = new Toast(context);
    final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.poizi_toast_layout, null);

    ImageView imgToastIcon = (ImageView) toastLayout.findViewById(R.id.imgToastIcon);
    TextView tvToastText = (TextView) toastLayout.findViewById(R.id.tvToastText);
    LinearLayout llPoiziToastRoot = (LinearLayout) toastLayout.findViewById(R.id.llPoiziToastRoot);

    initLlPoiziToastRoot(llPoiziToastRoot);
    initToastText(tvToastText);
    initToastIcon(imgToastIcon);

    toast.setView(toastLayout);

    toast.setDuration(poiziToastOptionModel.getDuration());

    setGravity(toast);

    toast.show();
}
 
开发者ID:Poizi,项目名称:PoiziToast,代码行数:22,代码来源:Exhibitioner.java

示例3: insertNameinDB

import android.widget.Toast; //导入方法依赖的package包/类
private void insertNameinDB() throws UnsupportedEncodingException {
    if (name.equals("")) {
        Context context = getActivity().getApplicationContext();
        CharSequence text = "Hei, nu ai niciun nume!";
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    } else {

        //inserare in baza de data a numelui si scorului
        Log.e("INSERT:", name + " " + score);
        new UserInsert().execute();
        Intent newActivityRanking = new Intent(getActivity(), RankingActivity.class);
        startActivity(newActivityRanking);
        getActivity().finish();

    }
}
 
开发者ID:cristian-cojocaru,项目名称:QuizApp-Android,代码行数:19,代码来源:FragScore.java

示例4: checkconnection

import android.widget.Toast; //导入方法依赖的package包/类
public void checkconnection()
{
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    android.net.NetworkInfo wifi = cm
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    android.net.NetworkInfo datac = cm
            .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if ((wifi != null & datac != null)
            && (wifi.isConnected() | datac.isConnected())) {
        //connection is avlilable
    }else{
        //no connection
        Toast toast = Toast.makeText(MainActivity.this, "No Internet Connection Please make Internet for Contine",
                Toast.LENGTH_SHORT);
        toast.show();
    }
}
 
开发者ID:Shobhit-pandey,项目名称:CollegeDoc,代码行数:18,代码来源:MainActivity.java

示例5: onCreate

import android.widget.Toast; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
        String line = null;
        while((line = in.readLine()) != null) {
            String word = line.trim();
            /**
             **
             **  YOUR CODE GOES HERE
             **
             **/
        }
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    LinearLayout verticalLayout = (LinearLayout) findViewById(R.id.vertical_layout);
    stackedLayout = new StackedLayout(this);
    verticalLayout.addView(stackedLayout, 3);

    View word1LinearLayout = findViewById(R.id.word1);
    word1LinearLayout.setOnTouchListener(new TouchListener());
    //word1LinearLayout.setOnDragListener(new DragListener());
    View word2LinearLayout = findViewById(R.id.word2);
    word2LinearLayout.setOnTouchListener(new TouchListener());
    //word2LinearLayout.setOnDragListener(new DragListener());
}
 
开发者ID:bricam,项目名称:wordstack,代码行数:33,代码来源:MainActivity.java

示例6: warnIfNoExternalStorage

import android.widget.Toast; //导入方法依赖的package包/类
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();
}
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:12,代码来源:ServerControlActivity.java

示例7: showWhiteSnackBar

import android.widget.Toast; //导入方法依赖的package包/类
public static void showWhiteSnackBar(int signed_in_message, AppCompatActivity compatActivity) {
    LayoutInflater inflater = compatActivity.getLayoutInflater();
    View layout = inflater.inflate(R.layout.custom_toast_view,
            (ViewGroup) compatActivity.findViewById(R.id.custom_toast_container));
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(signed_in_message);
    Toast toast = new Toast(compatActivity);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
    toast.show();
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:12,代码来源:Utils.java

示例8: onBackPressed

import android.widget.Toast; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else if (1 == mViewPager.getCurrentItem()) {
        mViewPager.setCurrentItem(0);
    } else {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Toast makeText = Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT);
        makeText.setDuration(Toast.LENGTH_SHORT);
        makeText.show();

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                doubleBackToExitPressedOnce = false;
            }
        }, 2000);
    }
}
 
开发者ID:Sayi,项目名称:RestClient,代码行数:28,代码来源:HomeActivity.java

示例9: showCustomToast

import android.widget.Toast; //导入方法依赖的package包/类
/** 显示自定义Toast提示(来自String) **/
protected void showCustomToast(String text) {
	View toastRoot = LayoutInflater.from(BaseActivity.this).inflate(
			R.layout.common_toast, null);
	((HandyTextView) toastRoot.findViewById(R.id.toast_text)).setText(text);
	Toast toast = new Toast(BaseActivity.this);
	toast.setGravity(Gravity.CENTER, 0, 0);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(toastRoot);
	toast.show();
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:12,代码来源:BaseActivity.java

示例10: popAlarmSetToast

import android.widget.Toast; //导入方法依赖的package包/类
/**
 * Display a toast that tells the user how long until the alarm
 * goes off.  This helps prevent "am/pm" mistakes.
 */
static void popAlarmSetToast(Context context, long timeInMillis) {
  String toastText = formatToast(context, timeInMillis);
  Toast toast = Toast.makeText(context, toastText, Toast.LENGTH_LONG);
  ToastMaster.setToast(toast);
  toast.show();
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:11,代码来源:SetAlarm_akt.java

示例11: showErrorToast

import android.widget.Toast; //导入方法依赖的package包/类
/**
 * 显示错误的Toast
 *
 * @param text String
 */
public static void showErrorToast(Context context, String text) {
    View view = View.inflate(context, R.layout.toast_view_prompt, null);
    TextView tv = (TextView) view.findViewById(R.id.tv_toast_prompt);
    tv.setText(text);
    tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toast_show_error, 0, 0, 0);

    Toast toast = getToast(context, view);
    toast.show();
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:15,代码来源:ToastPrompt.java

示例12: onPreferenceChange

import android.widget.Toast; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    // In this context, we're using the onPreferenceChange listener for checking whether the
    // radius setting was set to a valid value.

    //the error message that will be shown if an invalid value is entered
    Toast error = Toast.makeText(getContext(), "Please select a number greater than 0", Toast.LENGTH_SHORT);

    // Double check that the preference is the radius preference
    String sizeKey = getString(R.string.pref_radius_key);
    if (preference.getKey().equals(sizeKey)) {
        String radius = (String) newValue;
        try {
            double size = Double.parseDouble(radius);
            // If the number is outside of the acceptable range, show an error.
            if (size <= 0) {
                error.show();
                return false;
            }
        } catch (NumberFormatException nfe) {
            // If whatever the user entered can't be parsed to a number, show an error
            error.show();
            return false;
        }
    }

    //numbers seems to be valid; accept it
    return true;
}
 
开发者ID:Jugendhackt,项目名称:Camera-warner,代码行数:30,代码来源:SettingsFragment.java

示例13: showToastSavor

import android.widget.Toast; //导入方法依赖的package包/类
/**
 * 与app色调一致的自定义Toast
 * @param context
 * @param msg 要展示的信息
 */
public static void showToastSavor(Context context, String msg) {
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View inflate = layoutInflater.inflate(R.layout.view_text, null);
    ((TextView) inflate.findViewById(R.id.custom_toast)).setText(msg);
    Toast toast = new Toast(context);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setView(inflate);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.show();
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:16,代码来源:ToastUtil.java

示例14: customDisplay

import android.widget.Toast; //导入方法依赖的package包/类
private void customDisplay(String msg) {
    Toast tt = new Toast(this);
    LayoutInflater inflator = this.getLayoutInflater();
    View vv = inflator.inflate(R.layout.custom_toast_layout, null);
    TextView cTv = (TextView) vv.findViewById(R.id.cTv);
    cTv.setText(msg);
    vv.requestLayout();
    tt.setView(vv);
    tt.setGravity(Gravity.CENTER, 0, 0);
    tt.show();
}
 
开发者ID:shivam301296,项目名称:2048-TimeKiller,代码行数:12,代码来源:Game.java

示例15: show

import android.widget.Toast; //导入方法依赖的package包/类
/**
 * 显示吐司
 *
 * @param text     文本
 * @param duration 显示时长
 */
private static void show(CharSequence text, int duration) {
    cancel();
    if (customView != null) {
        sToast = new Toast(App.app);
        sToast.setView(customView);
        sToast.setDuration(duration);
    } else {
        sToast = Toast.makeText(App.app, text, duration);
    }
    sToast.setGravity(gravity, xOffset, yOffset);
    sToast.show();
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:19,代码来源:ToastUtils.java


注:本文中的android.widget.Toast.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。