if you enter only 5002 the it gets null value in space1 so it's crashed.To solve these problem you can do like this:
str=txt.getText().toString(); int space1=str.indexOf(" "); if(space!=null){ s=str.substring(0, space1); } else { s=str; } On Tue, Mar 6, 2012 at 11:06 AM, Jagruti Sangani < jagruti.sang...@inextrix.com> 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