我有一个AlertDialog,里面有一个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();