How to create EditText numeric (signed and unsigne

2019-08-01 22:13发布

this is a loop that creates a table of EditText and I wish they were numerical

for (int i = 0; i < 3; i++) {

tableRow = new TableRow(this); //oggetto di tipo tableRow
tableRow.setGravity(Gravity.CENTER);

for (int j = 0; j < 3 ; j++) {

values[i][j] = new EditText(this);
values[i][j].setText(" " + array[count]);
values[i][j].setPadding(10, 10, 10, 10);//spaziatura di ogni cella per i quattro lati
tableRow.addView(values[i][j]);
count++;
}

tableLayout.addView(tableRow);  
}

1条回答
甜甜的少女心
2楼-- · 2019-08-01 22:37
values[i][j].setInputType(InputType.TYPE_CLASS_NUMBER);

you can use the above line of code

Update try the below and thier combination

I've tried combining flags (in desperation to see if it would work):

values[i][j].setInputType(InputType.TYPE_CLASS_NUMBER);
values[i][j].setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL)
values[i][j].setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED)

refer this link for more inputtypes

查看更多
登录 后发表回答