问题
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:
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
来源:https://stackoverflow.com/questions/10302304/how-to-create-edittext-numeric-signed-and-unsigned-decimal-from-java-code