我在將字符串中的可編輯文本值存儲時遇到問題。我只是想存儲一個用戶輸入存儲在某個變量中的值。我在存儲一個值之後使用toast來檢查值是否存儲在其中,並且烤麪包沒有顯示任何值。我嘗試下面的代碼,但沒有發現它有幫助。不存儲字符串中的EditText vlaue
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);
}
});
}
}
你應該有你的編輯以前equestion ...而不是發佈新 – Pragnani
加秀()在吐司消息 – Pragnani
結束時,我不知道y爲這沒有編輯那裏..所以,你發佈了一個新的問題.. –