Re: [android-developers] Re: HOw to extract only number

2012-03-08 Thread Jagruti Sangani
Thanks harshita agrawal and Remote red.my problem solved befor you have
given me reply.But thanks again or your reply.

On Tue, Mar 6, 2012 at 11:27 AM, Marius Merkevicius wrote:

> Ok first things first.
> 1) As I develop, always use try/catch on these kind of operations, so they
> only show warnings, but wouldn't force-quit program.
> 2) Try putting a number only format in youre EditText. (I dont remember
> correctly but that's android:inputType:"number" or
> android:inputMethod:"number". That will prevent user from entering symbols,
> only numbers.
> 3) Try parsing options, here is a nice and simple examples to start to.
> http://pages.cs.wisc.edu/~hasti/cs302/examples/Parsing/parseString.html
> Have fun :)
>
>
> On Tuesday, March 6, 2012 7:36:54 AM UTC+2, Jagruti Sangani wrote:
>>
>> Hello,
>> I have textbox in that some time i will enter the onlu number like
>> 96350254 or  5002 those are not in fix length.and sometimes if select from
>> contact then in text box number will be with the name like "5002
>> jagruti".when i press the button then i want to pass only the number to the
>> other page so how can i send only number from textbox value.I made the
>> function and in that
>>str=txt.getText().toString();
>> int space1=str.indexOf(" ");
>> s=str.substring(0, space1);
>>
>> this work perfectly if in tye textbox "5002 jagruti" but when i enter
>> only 5002 then it will crash the application.so can anybody know how to do
>> successfully pass the number.
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: HOw to extract only number

2012-03-08 Thread Jagruti Sangani
Thanks it works now.

On Tue, Mar 6, 2012 at 5:46 PM, Remote Red  wrote:

>   str=txt.getText().toString();
>   int space1=str.indexOf(" ");
>   if ( space1 > 0 )
>s=str.substring(0, space1);
>   else
>s= str;
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: HOw to extract only number

2012-03-08 Thread Marius Merkevicius
Ok first things first. 
1) As I develop, always use try/catch on these kind of operations, so they 
only show warnings, but wouldn't force-quit program. 
2) Try putting a number only format in youre EditText. (I dont remember 
correctly but that's android:inputType:"number" or  
android:inputMethod:"number". That will prevent user from entering symbols, 
only numbers.
3) Try parsing options, here is a nice and simple examples to start to. 
http://pages.cs.wisc.edu/~hasti/cs302/examples/Parsing/parseString.html 
Have fun :)

On Tuesday, March 6, 2012 7:36:54 AM UTC+2, Jagruti Sangani wrote:
>
> Hello,
> I have textbox in that some time i will enter the onlu number like 
> 96350254 or  5002 those are not in fix length.and sometimes if select from 
> contact then in text box number will be with the name like "5002 
> jagruti".when i press the button then i want to pass only the number to the 
> other page so how can i send only number from textbox value.I made the 
> function and in that 
>str=txt.getText().toString();
> int space1=str.indexOf(" ");
> s=str.substring(0, space1);
>
> this work perfectly if in tye textbox "5002 jagruti" but when i enter only 
> 5002 then it will crash the application.so can anybody know how to do 
> successfully pass the number.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: HOw to extract only number

2012-03-06 Thread Remote Red
   str=txt.getText().toString();
   int space1=str.indexOf(" ");
   if ( space1 > 0 )
s=str.substring(0, space1);
   else
s= str;

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en