使用我创建的键盘布局输入编辑文本值时,光标位于起始位置。光标位置不会根据输入的值移动。有没有办法实现这一点。代码如下:
String zip;
OnClickListener clickListener = new OnClickListener() {
@Override
public void onClick(View v) {
final int id = v.getId();
if (id == R.id.button0) {
zip = zip + "0";
editZip.setText(zip);
} else if (id == R.id.button1) {
zip = zip + "1";
editZip.setText(zip);
} else if (id == R.id.button2) {
zip = zip + "2";
editZip.setText(zip);
} else if (id == R.id.button3) {
zip = zip + "3";
editZip.setText(zip);
} else if (id == R.id.button4) {
zip = zip + "4";
//editZip.requestFocus();
editZip.setText(zip);
} else if (id == R.id.button5) {
zip = zip + "5";
editZip.setText(zip);
} else if (id == R.id.button6) {
zip = zip + "6";
editZip.setText(zip);
} else if (id == R.id.button7) {
zip = zip + "7";
editZip.setText(zip);
} else if (id == R.id.button8) {
zip = zip + "8";
editZip.setText(zip);
} else if (id == R.id.button9) {
zip = zip + "9";
editZip.setText(zip);
} else if (id == R.id.buttonDel) {
if (zip.length() > 0) {
zip = zip.substring(0, zip.length()-1);
editZip.setText(zip);
}
}
}
};