未存储的EditText vlaue在字符串 [英] Not storing the EditText vlaue in a string
问题描述
我有在存储在一个字符串编辑文本能值的问题。我只是想用来存储用户输入其存储在某些变量的值。我用吐司只是存储的值后检查值是否在IT卖场或不和烤面包不显示任何值。我尝试以下code,但没有找到它的帮助。
包com.example.electropollsys;进口android.annotation.Sup pressLint;
进口android.app.Activity;
进口android.content.Intent;
进口android.os.Bundle;
进口android.view.View;
进口android.view.Window;
进口android.view.WindowManager;
进口android.widget.Button;
进口android.widget.EditText;
进口android.widget.TextView;
进口android.widget.Toast;公共类CreateAcc延伸活动{
保护无效的onCreate(捆绑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); 最后键b =(按钮)findViewById(R.id.button3);
b.setOnClickListener(新View.OnClickListener(){
公共无效的onClick(视图v){ 意图I =新意图(CreateAcc.this,SignIn.class);
i.addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(ⅰ);
}
}); 最终按钮=(按钮)findViewById(R.id.button1);
a.setOnClickListener(新View.OnClickListener(){
@燮pressLint(ShowToast)
公共无效的onClick(视图v){ EditText上输入1 =(EditText上)findViewById(R.id.fname1);
。字符串FNAME = input1.getEditableText()的toString(); EditText上输入2 =(EditText上)findViewById(R.id.lname1);
。字符串LNAME = input2.getEditableText()的toString(); Toast.makeText(CreateAcc.this,......+ FNAME +......,Toast.LENGTH_LONG);
Toast.makeText(CreateAcc.this,......+ LNAME +......,Toast.LENGTH_LONG); }
});
}
}
尝试:
Toast.makeText(CreateAcc.this,......+ FNAME +......,Toast.LENGTH_LONG).show();
Toast.makeText(CreateAcc.this,......+ LNAME +......,Toast.LENGTH_LONG).show();
敬酒不显示,除非显示()
方法被调用。在 makeText()
方法返回一个吐司对象,则必须使用显示敬酒。
您通常会得到关于这个皮棉警告,但你似乎有燮$ P $与 @燮pressLint(ShowToast)pssed它
。
I am having a problem in storing a Edit able Text value in a string. I just want to store a value that user enter store it in some variable. i used toast just after storing a value to check whether the value is store in it or not and toast doesn't show any value. i try the following code but didnt find it helpful.
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);
}
});
}
}
Try:
Toast.makeText(CreateAcc.this,"...."+fname+"...." , Toast.LENGTH_LONG).show();
Toast.makeText(CreateAcc.this,"...."+lname+"...." , Toast.LENGTH_LONG).show();
Toasts do not show unless the show()
method is called. the makeText()
method returns a Toast object which you must use to display the toast.
You normally get a lint warning about this, but you seem to have suppressed it with @SuppressLint("ShowToast")
.
这篇关于未存储的EditText vlaue在字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!