Android 不在字符串中存储EditText vlaue

Android 不在字符串中存储EditText vlaue,android,Android,我在字符串中存储可编辑的文本值时遇到问题。我只想存储一个用户输入的值,并将其存储在某个变量中。我在存储一个值之后使用toast来检查该值是否存储在其中,而toast不显示任何值。我尝试了以下代码,但没有发现它有帮助 package com.example.electropollsys; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; i

我在字符串中存储可编辑的文本值时遇到问题。我只想存储一个用户输入的值,并将其存储在某个变量中。我在存储一个值之后使用toast来检查该值是否存储在其中,而toast不显示任何值。我尝试了以下代码,但没有发现它有帮助

    package com.example.electropollsys;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;



public class CreateAcc extends Activity {
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);


    requestWindowFeature(Window.FEATURE_NO_TITLE);
     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
             WindowManager.LayoutParams.FLAG_FULLSCREEN);

     setContentView(R.layout.create_acc);

     final Button b = (Button) findViewById(R.id.button3);
     b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {

             Intent i = new Intent(CreateAcc.this, SignIn.class);
            i.addFlags(
                Intent.FLAG_ACTIVITY_CLEAR_TOP |
                Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);
         }


     });

     final Button a = (Button) findViewById(R.id.button1);
     a.setOnClickListener(new View.OnClickListener() {


            @SuppressLint("ShowToast")
            public void onClick(View v){

                EditText input1= (EditText)findViewById(R.id.fname1); 
                String fname = input1.getEditableText().toString();

                EditText input2= (EditText) findViewById(R.id.lname1); 
                String lname = input2.getEditableText().toString();

                Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG);
                Toast.makeText(CreateAcc.this,"...."+lname+"...." , Toast.LENGTH_LONG);

              }
         });
    }
    }
尝试:

除非调用
show()
方法,否则不会显示祝酒词。
makeText()
方法返回一个Toast对象,您必须使用它来显示Toast

您通常会收到一个关于此的lint警告,但您似乎用
@suppressint(“showtoos”)
抑制了它,您确实喜欢这种方式

Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG);
使用它可以初始化toast对象并返回该对象,但要显示toast通知,需要对该对象调用show方法

不要写这个,写这个

Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG).show();

您忘记在末尾添加.show()

提及


你应该编辑你以前的等式…而不是在toast消息的末尾发布新的oneadd show()。我不知道,在那里没有任何编辑内容。。因此,y我发布了一个新问题..在问题中,你说你在Toast中得到空字符串,friend Toast不会出现在屏幕上如何得到空Toast这是你的问题@user2044144请单击勾号将其标记为解决方案,然后
Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG).show();
Toast toast = Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG);
toast.show();