android.widget.Toast#makeText ( )源码实例Demo

下面列出了android.widget.Toast#makeText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mollyim-android   文件: ConversationActivity.java
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
  if (menu == null) {
    return super.onMenuOpened(featureId, null);
  }

  if (!SignalStore.uiHints().hasSeenGroupSettingsMenuToast()) {
    MenuItem settingsMenuItem = menu.findItem(R.id.menu_group_settings);

    if (settingsMenuItem != null && settingsMenuItem.isVisible()) {
      Toast toast = Toast.makeText(this, R.string.ConversationActivity__more_options_now_in_group_settings, Toast.LENGTH_SHORT);

      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();

      SignalStore.uiHints().markHasSeenGroupSettingsMenuToast();
    }
  }

  return super.onMenuOpened(featureId, menu);
}
 
源代码2 项目: stynico   文件: wlflActivity.java
public void ShowToast(String text)
   {
       if (!TextUtils.isEmpty(text))
{
           try
    {
               if (mToast == null)
	{
                   mToast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
               }
	else
	{
                   mToast.setText(text);
               }
               mToast.show();
           }
    catch (Exception e)
    {
               e.printStackTrace();
           }
       }
   }
 
源代码3 项目: Cirrus_depricated   文件: FileDisplayActivity.java
/**
 * Updates the view associated to the activity after the finish of an operation trying to copy a
 * file.
 *
 * @param operation Copy operation performed.
 * @param result    Result of the copy operation.
 */
private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        refreshListOfFilesFragment();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(FileDisplayActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message ", e);
        }
    }
}
 
源代码4 项目: QrScan   文件: ToastUtil.java
public static void showToast(Context context, String message, int duration, int gravity, int xOffset, int yOffset) {
    if (message == null){
        return;
    }

    if (sToast == null) {
        sToast = Toast.makeText(context, "", duration);
    } else {
        sToast.cancel();
        sToast = Toast.makeText(context, "", duration);
    }
    sToast.setText(message);
    sToast.setDuration(duration);
    sToast.setGravity(gravity, xOffset, yOffset);
    sToast.show();
}
 
源代码5 项目: microbit   文件: CameraActivity_OldAPI.java
/**
 * Starts taking a picture countdown with playing an audio
 * and showing a text countdown for defined interval, and then takes a picture.
 */
private void startTakePicCounter() {

    playAudioPresenter.setInternalPathForPlay(InternalPaths.TAKING_PHOTO_AUDIO);
    playAudioPresenter.start();

    @SuppressLint("ShowToast") final Toast toast = Toast.makeText(MBApp.getApp().getApplicationContext(), "bbb", Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);

    //Toast.LENGTH_SHORT will keep the toast for 2s, our interval is 1s and calling toast.show()
    //after 1s will cause some count to be missed. Only call toast.show() just before 2s interval.
    //Also add delay to show the "Ready" toast.
    new CountDownTimer(Constants.PIC_COUNTER_DURATION_MILLIS, Constants.PIC_COUNTER_INTERVAL_MILLIS) {

        public void onTick(long millisUntilFinished) {
            int count = (int) millisUntilFinished / Constants.PIC_COUNTER_INTERVAL_MILLIS;
            toast.setText("Ready in... " + count);
            if(count % 2 != 0)
                toast.show();
        }

        public void onFinish() {
            toast.setText("Ready");
            toast.show();
            mButtonClick.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mButtonClick.callOnClick();
                }

            }, 200);
        }
    }.start();
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_word_selection);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new PathDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
}
 
源代码7 项目: cube-sdk   文件: CubeFragmentActivity.java
/**
 * process back pressed
 */
@Override
public void onBackPressed() {

    // process back for fragment
    if (processBackPressed()) {
        return;
    }

    // process back for fragment
    boolean enableBackPressed = true;
    if (mCurrentFragment != null) {
        enableBackPressed = !mCurrentFragment.processBackPressed();
    }
    if (enableBackPressed) {
        int cnt = getSupportFragmentManager().getBackStackEntryCount();
        if (cnt <= 1 && isTaskRoot()) {
            String closeWarningHint = getCloseWarning();
            if (!mCloseWarned && !TextUtils.isEmpty(closeWarningHint)) {
                Toast toast = Toast.makeText(this, closeWarningHint, Toast.LENGTH_SHORT);
                toast.show();
                mCloseWarned = true;
            } else {
                doReturnBack();
            }
        } else {
            mCloseWarned = false;
            doReturnBack();
        }
    }
}
 
源代码8 项目: sctalk   文件: MessageActivity.java
public void showToast(int resId) {
    String text = getResources().getString(resId);
    if (mToast == null) {
        mToast = Toast.makeText(MessageActivity.this, text, Toast.LENGTH_SHORT);
    } else {
        mToast.setText(text);
        mToast.setDuration(Toast.LENGTH_SHORT);
    }
    mToast.setGravity(Gravity.CENTER, 0, 0);
    mToast.show();
}
 
源代码9 项目: AutoInteraction-Library   文件: Util.java
public static Toast showToast(Context context, int i) {

        if (mContext == context) {
            mToast.setText(i);
        } else {
            mContext = context;
            mToast = Toast.makeText(context, i, Toast.LENGTH_SHORT);
        }
        mToast.show();
        return mToast;
    }
 
源代码10 项目: stynico   文件: ToastUtil.java
public static void show(Context context,CharSequence character,int duration){
    if(toast==null){
        toast=Toast.makeText(context,character,duration);
    }else {
        toast.setText(character);
        toast.setDuration(duration);
    }
    toast.show();
}
 
源代码11 项目: UltimateAndroid   文件: ToastUtil.java
/**
 * 长时间显示Toast
 *
 * @param context
 * @param message
 */
public static void showLong(Context context, int message) {
    if (null == toast) {
        toast = Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_LONG);
        // toast.setGravity(Gravity.CENTER, 0, 0);
    } else {
        toast.setText(message);
    }
    toast.show();
}
 
@Override
public void onHeaderClick(AdapterView<?> parent, View view, long id) {
    String text = "Header " + ((TextView)view.findViewById(android.R.id.text1)).getText() + " was tapped.";
    if (mToast == null) {
        mToast = Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT);
    } else {
        mToast.setText(text);
    }
    mToast.show();
}
 
源代码13 项目: Stock-Hawk   文件: MainActivity.java
@Override
public void showStockAlreadyExist() {
    Toast toast = Toast.makeText(this, getResources().getString(R.string.stocks_already_exist),
            Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, Gravity.CENTER, 0);
    toast.show();
}
 
源代码14 项目: Wrox-ProfessionalAndroid-4E   文件: MainActivity.java
private void listing13_26() {
  // Listing 13-26: Displaying a Toast
  Context context = this;
  String msg = "To health and happiness!";
  int duration = Toast.LENGTH_SHORT;
  Toast toast = Toast.makeText(context, msg, duration);

  // Remember, you must *always* call show()
  toast.show();
}
 
源代码15 项目: LoyalNativeSlider   文件: BigScreenDemo.java
@Override
public void onSliderClick(BaseSliderView coreSlider) {
    Toast.makeText(this, "Clicked Item", Toast.LENGTH_SHORT);
}
 
源代码16 项目: scrog   文件: HUDView.java
private void init(){
    TapDetector tapDetector = new TapDetector(mPaint, this, colMan);
    mDetector = new GestureDetector(mContext, tapDetector);
    Toast toast = Toast.makeText(mContext, "You may double tap, move or resize info window", Toast.LENGTH_LONG);
    toast.show();
}
 
源代码17 项目: EasyHttp   文件: RxGetActivity.java
@OnClick(R.id.go)
public void go() {
    Editable url = urlView.getText();

    if (TextUtils.isEmpty(url)) {
        Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
        return;
    }

    RxEasyHttp.get(url.toString(), new RxEasyStringConverter())
            .doOnSubscribe(new Consumer<Subscription>() {
                @Override
                public void accept(@NonNull Subscription subscription) throws Exception {
                    dialog.show();
                    body.setText("");
                }
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new FlowableSubscriber<String>() {
                @Override
                public void onSubscribe(Subscription s) {
                    s.request(Long.MAX_VALUE);
                    dialog.show();
                    body.setText("");
                }

                @Override
                public void onNext(String response) {
                    body.setText(response);
                }

                @Override
                public void onError(Throwable t) {
                    body.setText(t.toString());
                }

                @Override
                public void onComplete() {
                    dialog.cancel();
                }
            });
}
 
源代码18 项目: ud867   文件: MainActivity.java
public void tellJoke(View view) {

        Context context = this;
        CharSequence text = this.getString(R.string.toast_text);
        int duration = Toast.LENGTH_LONG;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();


    }
 
源代码19 项目: RetailStore   文件: Boast.java
/**
 * Make a standard {@link Boast} that just contains a text view with the
 * text from a resource.
 *
 * @param context  The context to use. Usually your {@link android.app.Application}
 *                 or {@link android.app.Activity} object.
 * @param resId    The resource id of the string resource to use. Can be formatted
 *                 text.
 * @param duration How long to display the message. Either {@link //LENGTH_SHORT} or
 *                 {@link //LENGTH_LONG}
 * @throws Resources.NotFoundException if the resource can't be found.
 */
@SuppressLint("ShowToast")
public static Boast makeText(Context context, int resId, int duration)
        throws Resources.NotFoundException {
    return new Boast(Toast.makeText(context, resId, duration));
}
 
源代码20 项目: Android-Architecture-Fairy   文件: MainPresenter.java
/**
 * Creat a Toast object with given message
 * @param msg   Toast message
 * @return      A Toast object
 */
private Toast makeToast(String msg) {
    return Toast.makeText(getView().getAppContext(), msg, Toast.LENGTH_SHORT);
}