吐司没有显示onButtonClick

 黄志琴文菱 发布于 2023-02-13 17:13

我有一个吐司,应该在我按下"提交"按钮时显示:

这是我的代码:

@SuppressLint("ShowToast")
    public void ButtonOnClick(View view){
        SharedPreferences sharedPref= getSharedPreferences("chaosautoreply", 0);
        SharedPreferences.Editor editor= sharedPref.edit();
        TextView tvMessage = (TextView) findViewById(R.id.editMessage);
        String message = tvMessage.getText().toString();
        editor.putString("message", message).commit();
        Toast.makeText(getApplicationContext(), "Updated Successfully", 10);
    }

这是我的布局:

    

没有要显示的错误或logcats.提交似乎起作用,但它不是Toast.

1 个回答
  • Toast.makeText(getApplicationContext(), "Updated Successfully", 10).show();
    

    2023-02-13 17:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有