public class MainActivity extends ActionBarActivity {
EditText edtPasscode1;
EditText edtPasscode2;
EditText edtPasscode3;
EditText edtPasscode4;
Button button1;
StringBuilder sb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtPasscode1 = (EditText) findViewById(R.id.editText1);
edtPasscode2 = (EditText) findViewById(R.id.editText2);
edtPasscode3 = (EditText) findViewById(R.id.editText3);
edtPasscode4 = (EditText) findViewById(R.id.editText4);
button1 = (Button) findViewById(R.id.button1);
sb = new StringBuilder();
sb.append(edtPasscode1.getText().toString());
sb.append(edtPasscode2.getText().toString());
sb.append(edtPasscode3.getText().toString());
sb.append(edtPasscode4.getText().toString());
edtPasscode1.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
if (sb.length() == 0 & edtPasscode1.length() == 1) {
sb.append(s);
edtPasscode1.clearFocus();
edtPasscode2.requestFocus();
edtPasscode2.setCursorVisible(true);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
if (sb.length() == 1) {
sb.deleteCharAt(0);
}
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if (sb.length() == 0) {
edtPasscode1.requestFocus();
}
}
});
edtPasscode2.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
if (sb.length() == 0 & edtPasscode2.length() == 1) {
sb.append(arg0);
edtPasscode2.clearFocus();
edtPasscode3.requestFocus();
edtPasscode3.setCursorVisible(true);
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
sb.deleteCharAt(0);
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
if (sb.length() == 0) {
edtPasscode2.requestFocus();
}
}
});
edtPasscode3.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
if (sb.length() == 0 & edtPasscode3.length() == 1) {
sb.append(s);
edtPasscode3.clearFocus();
edtPasscode4.requestFocus();
edtPasscode4.setCursorVisible(true);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
sb.deleteCharAt(0);
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if (sb.length() == 0) {
edtPasscode3.requestFocus();
}
}
});
edtPasscode4.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
if (sb.length() == 0 & edtPasscode4.length() == 1) {
sb.append(arg0);
edtPasscode4.clearFocus();
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), sb.append(arg0).toString(), 10000).show();
}
});
}
}
所有edite文本視圖進入編輯文本的所有文本後,這是我的代碼,我有4個編輯文本時,我在第一編輯文本鍵光標移動到另一個編輯輸入值當輸入第二個文本時編輯文本鍵光標移動到第三個文本時輸入第三個編輯文本鍵光標移動到第四我想當我輸入第四編輯文本我想要顯示所有文本值在吐司ie edittext1.gettext()+ edittext2.gettext( )+ edittext3.gettext()+ edittext4.gettext()= 1234其中1是輸入編輯text1 2是輸入2 3是輸入3 4是輸入4分別請建議我哪裏做錯了。爲什麼它不顯示所有文本值顯示onlu 34請幫助!添加並顯示在土司的所有文本在安卓
OK讓我試試implening它 – user2794306
什麼,我有這個做,我應該刪除sb.deleteCharAt(0); – user2794306
我在做什麼,我必須刪除 – user2794306