Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello :)

How can I validate a text view in android to handle positive integer numbers ?

I don't want it to accept any character or signs etc...

thank you all
Posted

This may be solve ur problem

Method 1:
TextView txt=(TextView)findViewById(R.id.txtview);
txt.setInputType(InputType.TYPE_CLASS_NUMBER);

Method2: in XML file
add this line
<textview>
android:id="@+id/txtview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ddigits="0123456789"
android:text="@string/hello" />
 
Share this answer
 
I found the selution,

by adding: android:inputType="number" to your Edit text
 
Share this answer
 
Comments
Member 11063501 16-Oct-14 2:35am    
hey i want to make pc remote controller can anyone help me out regards......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900