我有一个 AlertDialog 并将 EditText 放入其中,但我希望我的 EditText 仅接受以下输入:
(0,1,2,3,4,5,6,7,8,9,.,,)
我怎样才能做到这一点?
这是我的代码:
final AlertDialog.Builder alert = new AlertDialog.Builder(Treatment.this);
alert.setTitle("Weigthed Mean!");
alert.setIcon(R.drawable.droid);
Bundle b = getIntent().getExtras();
final TextView sum = (TextView) findViewById(R.id.fakeDB);
sum.setText(b.getCharSequence("input"));
final EditText x = new EditText (Treatment.this);
final EditText y = new EditText (Treatment.this);
x.setText(sum.getText().toString());
y.setHint("Enter the weights to the x values");
LinearLayout ll=new LinearLayout(Treatment.this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(x);
ll.addView(y);
alert.setView(ll);
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
alert.setOnCancelListener(null);
}
});
alert.create();
alert.show();