當前位置: 首頁>>代碼示例>>Java>>正文


Java Toast類代碼示例

本文整理匯總了Java中android.widget.Toast的典型用法代碼示例。如果您正苦於以下問題:Java Toast類的具體用法?Java Toast怎麽用?Java Toast使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Toast類屬於android.widget包,在下文中一共展示了Toast類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPreferenceChange

import android.widget.Toast; //導入依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    Toast error = Toast.makeText(getContext(), "Please select a number between 0.1 and 3", Toast.LENGTH_SHORT);

    String sizeKey = getString(R.string.pref_size_key);
    if (preference.getKey().equals(sizeKey)) {
        String stringSize = ((String) newValue).trim();

        try {
            float size = Float.parseFloat(stringSize);
            if (size > 3 || size <= 0.1) {
                error.show();
                return false;
            }
        } catch (NumberFormatException nfe) {
            error.show();
            return false;
        }
    }
    return true;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:22,代碼來源:SettingsFragment.java

示例2: onActivityResult

import android.widget.Toast; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            //mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed, update UI appropriately
            // [START_EXCLUDE]
            //updateUI(null);
            // [END_EXCLUDE]
            Toast.makeText(LoginActivity.this, "Authentication failed.",
                    Toast.LENGTH_SHORT).show();
        }
    }
}
 
開發者ID:nSpider,項目名稱:Paathshala,代碼行數:23,代碼來源:LoginActivity.java

示例3: onActivityResult

import android.widget.Toast; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case PERSON_INFO_SETTING_CODE:
            switch (resultCode){
                case RESULT_OK:
                    init();
                    return;
            }
            break;
        case USER_SAFE_CODE:
            break;
        case REPORT_QUESTIONG_CODE:
            Toast.makeText(getActivity(),"感謝您的建議~~",Toast.LENGTH_SHORT).show();
            break;
        case PERSON_LOGIN_CODE:
            if (AppKt.getGlobalUid() == 0) {
                Toast.makeText(getActivity(), "未登陸", Toast.LENGTH_LONG).show();
            }
            break;
    }
    return;
}
 
開發者ID:toonine,項目名稱:BalaFM,代碼行數:24,代碼來源:PersonFragment.java

示例4: setNickname

import android.widget.Toast; //導入依賴的package包/類
/**
 * 更新群昵稱
 *
 * @param name
 */
private void setNickname(final String name) {
    DialogMaker.showProgressDialog(this, getString(R.string.empty), true);
    NIMClient.getService(TeamService.class).updateMemberNick(teamId, account, name).setCallback(new RequestCallback<Void>() {
        @Override
        public void onSuccess(Void param) {
            DialogMaker.dismissProgressDialog();
            nickName.setText(name != null ? name : getString(R.string.team_nickname_none));
            Toast.makeText(AdvancedTeamMemberInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onFailed(int code) {
            DialogMaker.dismissProgressDialog();
            Toast.makeText(AdvancedTeamMemberInfoActivity.this, String.format(getString(R.string.update_failed), code),
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onException(Throwable exception) {
            DialogMaker.dismissProgressDialog();
        }
    });
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:29,代碼來源:AdvancedTeamMemberInfoActivity.java

示例5: sendFeedback

import android.widget.Toast; //導入依賴的package包/類
void sendFeedback()
{
    String feedback;

    String subject = "Feedback";
    feedback=fftext.getText().toString();
    if(!feedback.trim().isEmpty())
    {

        Log.i("Send email", "");
        String TO = "[email protected]";

        Intent send = new Intent(Intent.ACTION_SENDTO);
        String uriText = "mailto:" + Uri.encode(TO) +
                "?subject=" + Uri.encode(subject) +
                "&body=" + Uri.encode(feedback);
        Uri uri = Uri.parse(uriText);

        send.setData(uri);
        startActivity(Intent.createChooser(send, "Send mail..."));
    }
    else
    {
        Toast.makeText(getApplicationContext(), "Please Enter Text in Feedback Details", Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:sid24rane,項目名稱:Personal-Chef,代碼行數:27,代碼來源:Feedback.java

示例6: showToast

import android.widget.Toast; //導入依賴的package包/類
public static void showToast(String msg, int duration) {
    final Timer timer = new Timer();
    final Toast toast = Toast.makeText(King.getApplicationContext(), msg, Toast.LENGTH_LONG);
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            toast.show();
        }
    }, 0, 1000);

    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            toast.cancel();
            timer.cancel();
        }
    }, duration);

}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:20,代碼來源:ToastUtils.java

示例7: updateTeamInfo

import android.widget.Toast; //導入依賴的package包/類
/**
 * 更新群信息
 *
 * @param t
 */
private void updateTeamInfo(final Team t) {
    this.team = t;

    if (team == null) {
        Toast.makeText(this, getString(R.string.team_not_exist), Toast.LENGTH_SHORT).show();
        finish();
        return;
    } else {
        creator = team.getCreator();
        if (creator.equals(NimUIKit.getAccount())) {
            isSelfAdmin = true;
        }

        setTitle(team.getName());
    }

    teamHeadImage.loadTeamIconByTeam(team);
    teamNameText.setText(team.getName());
    teamIdText.setText(team.getId());
    teamCreateTimeText.setText(TimeUtil.getTimeShowString(team.getCreateTime(), true));

    ((TextView) layoutTeamName.findViewById(R.id.item_detail)).setText(team.getName());
    introduceEdit.setText(team.getIntroduce());
    extensionTextView.setText(team.getExtension());
    notificationConfigText.setText(team.mute() ? "關閉" : "開啟");
    memberCountText.setText(String.format("共%d人", team.getMemberCount()));

    setAnnouncement(team.getAnnouncement());
    setAuthenticationText(team.getVerifyType());
    updateInviteText(team.getTeamInviteMode());
    updateInfoUpateText(team.getTeamUpdateMode());
    updateBeInvitedText(team.getTeamBeInviteMode());
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:39,代碼來源:AdvancedTeamInfoActivity.java

示例8: onClick

import android.widget.Toast; //導入依賴的package包/類
@Override public void onClick(View v) {
  if (mail != null) {
    presenter.starMail(mail, !mail.isStarred());
  } else {
    Toast.makeText(getActivity(), R.string.error_wait_mail_loaded, Toast.LENGTH_SHORT).show();
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:DetailsFragment.java

示例9: onActivityResult

import android.widget.Toast; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_SIGNUP) {
        if (resultCode == RESULT_OK) {

            // TODO: Implement successful signup logic here
            // By default we just finish the Activity and log them in automatically
            Toast.makeText(getBaseContext(), "Welcome to ChewSnap!", Toast.LENGTH_LONG).show();
            onLoginSuccess();
            //this.finish();
        }
    }
}
 
開發者ID:xeliot,項目名稱:ChewSnap,代碼行數:14,代碼來源:LoginActivity.java

示例10: onActivityResult

import android.widget.Toast; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        if (result.getContents() == null) {
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            handleDecodeInternally(result.getContents());
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:13,代碼來源:WXDebugActivity.java

示例11: singleChoiceDialog

import android.widget.Toast; //導入依賴的package包/類
/**
 * 帶單選按鈕的Dialog
 *
 * @param view
 */
public void singleChoiceDialog(View view) {
    final SingleChoiceDialog dialog = SmartisanDialog.createSingleChoiceDialog(this);
    dialog.setTitle("蜂窩移動數據")
        .setLeftBtnText("取消")
        .setSingleChoiceItems(new String[]{"關", "使用 SIM 卡 1", "使用 SIM 卡 2"}, 0)
        .show();
    dialog.setOnSingleChoiceSelectListener(new OnSingleChoiceSelectListener() {
        @Override
        public void onSelect(int position) {
            Toast.makeText(MainActivity.this, "position = " + position, Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });
    dialog.setOnBtnSelectListener(new SingleChoiceDialog.OnBtnSelectListener() {
        @Override
        public void onLeftSelect() {
            dialog.dismiss();
        }

        @Override
        public void onRightSelect() {

        }
    });
}
 
開發者ID:liying2008,項目名稱:SmartisanDialog,代碼行數:31,代碼來源:MainActivity.java

示例12: updatePasswordClickEvent

import android.widget.Toast; //導入依賴的package包/類
private void updatePasswordClickEvent() {
    mUpdateCompile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            oldPaw = mUpdateOldPassword.getText().toString().trim();
            newPaw = mUpdateNewPassword.getText().toString().trim();

            if (TextUtils.isEmpty(oldPaw)) {
                Toast.makeText(UpdatePasswordActivity.this, "請輸入舊密碼!", Toast.LENGTH_SHORT).show();
            } else if (TextUtils.isEmpty(newPaw)) {
                Toast.makeText(UpdatePasswordActivity.this, "請輸入新密碼!", Toast.LENGTH_SHORT).show();
            } else {
                if (mMyUser != null) {
                    MyUser.updateCurrentUserPassword(oldPaw, newPaw, new UpdateListener() {
                        @Override
                        public void done(BmobException e) {
                            if (e == null) {
                                PersonSettingActivity.sSettingActivity.finishAfterTransition();
                                Toast.makeText(UpdatePasswordActivity.this,
                                        "修改成功,請用新密碼登錄!", Toast.LENGTH_SHORT).show();
                                Intent intent = new Intent(UpdatePasswordActivity.this,
                                        LoginActivity.class);
                                startActivity(intent);
                                finishAfterTransition();
                            } else {
                                Toast.makeText(UpdatePasswordActivity.this,
                                        "修改失敗,請重新檢查!", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }
        }
    });
}
 
開發者ID:struggledhard,項目名稱:USay,代碼行數:36,代碼來源:UpdatePasswordActivity.java

示例13: onCheckedChange

import android.widget.Toast; //導入依賴的package包/類
@Override
public <V extends View & Checkable> void onCheckedChange(ExampleViewHolder vh, V view, boolean isChecked) {
    if (view.isPressed()) {
        Toast.makeText(
                MainActivity.this,
                String.format(
                        "position=%d; label=%s; isChecked=%b;",
                        vh.getAdapterPosition(),
                        vh.getRadioButton().getText(),
                        isChecked
                ),
                Toast.LENGTH_SHORT
        ).show();
    }
}
 
開發者ID:S64,項目名稱:android-radiobutton-extended,代碼行數:16,代碼來源:MainActivity.java

示例14: startResultActivity

import android.widget.Toast; //導入依賴的package包/類
/**
 * Method to start the ResultActivity once all the data is loaded.
 * Creates new intent with the read data
 * @param pubKey The public key.
 * @param signedTransactions Signed data.
 * @param voter The voter.
 */
public void startResultActivity(PublicKey pubKey, ArrayList<byte[]> signedTransactions, Voter voter) {
    if(pubKey != null && signedTransactions != null) {

        Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
        intent.putExtra("voter", voter);
        intent.putExtra("pubKey", pubKey);
        intent.putExtra("signedTransactions", signedTransactions);
        startActivity(intent);
        finish();
    } else {
        Toast.makeText(this, getString(R.string.NFC_error), Toast.LENGTH_LONG).show();
        progressView.setImageResource(R.drawable.nfc_icon_empty);
    }
}
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:22,代碼來源:PassportConActivity.java

示例15: advancedImportDialog

import android.widget.Toast; //導入依賴的package包/類
private void advancedImportDialog(Context context) {
    LayoutInflater inflater = getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_advanced_import, (ViewGroup) findViewById(R.id.dialog_layout_import_advanced));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.import_advanced);
    final TextInputEditText group = mView.findViewById(R.id.edittext_import_advanced_group);
    final TextInputEditText word = mView.findViewById(R.id.edittext_import_advanced_word);
    final CheckBox ignoreChangeLine = mView.findViewById(R.id.checkbox_import_advanced_ignore_change_line);
    builder.setPositiveButton(R.string.import_file, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String groupReg = group.getText().toString();
            String wordReg = word.getText().toString();
            if (!groupReg.isEmpty()) {
                if (!wordReg.isEmpty()) {
                    int result = ImportMethod.extraFileRegImporter(DictionaryPath, DictionaryName, groupReg, wordReg, ignoreChangeLine.isChecked());
                    if (result == Config.IMPORT_OK) {
                        Toast.makeText(ImportActivity.this, R.string.import_success, Toast.LENGTH_SHORT).show();
                        finish();
                    } else if (result == Config.IMPORT_FILE_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_file_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_OUTPUT_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_output_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_GROUP_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_WORDS_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                    }
                } else {
                    Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                }
            } else {
                Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
開發者ID:XFY9326,項目名稱:CatchSpy,代碼行數:41,代碼來源:ImportActivity.java


注:本文中的android.widget.Toast類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。