当前位置: 首页>>代码示例>>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;未经允许,请勿转载。