我使用selectAll()函數,但它似乎沒有做任何事情。有沒有辦法讓文字突出顯示,這樣他們不必退格,然後重新輸入?選擇所有警告彈出文本selectAll()
void GetQuantity()
{
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Quantity");
alert.setMessage("Enter Quantity");
final EditText input = new EditText(this);
alert.setView(input);
input.setText("1");
// android:selectAllOnFocus="true"
input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.selectAll();
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Quantity =Double.parseDouble(input.getText().toString());
btnQuan.setText(input.getText().toString());
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// do nothing
}
});
alert.show();
}
如果您發佈實施方案將非常有用... – moonlightcheese 2011-06-22 18:15:06