I have a slider that let’s me dynamically add a number of EditText fields.
This is the code I use:
EditText editText = new EditText(getActivity());
editText.setId(i);
editText.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
editText.setInputType(4096);
linearLayout.addView(editText);
editText.setHint("Cash Flow " + i);
i++;
This is in a while loop that makes sure the number of fields created = number on the slider. Anyways, the setInputType according to this doesn’t work for all values. For example, if I put 2 in it, it will automatically have the keyboard only as the “number&signs” portion.
However, I need the person to be able to enter negative numbers (i.e. a negative sign before the number).
I figured TYPE_NUMBER_FLAG_SIGNED with the ID 4096 should do the trick, but I can still enter letters and stuff in the field…
What is wrong?
The TYPE_NUMBER_FLAG_SIGNED is a flag and not a input type,what you must do is write it like this: