Re: [android-beginners] Re: StringToFloat code
That or the constructor that takes a string - but anything over making your own parser... On 19 Jun 2010, at 22:12, Raymond Rodgers wrote: > I think he was specifically referring to the parseFloat() function... This is > a direct link to a slightly different version of the api he referenced... > http://java.sun.com/javase/7/docs/api/java/lang/Float.html#parseFloat(java.lang.String) > > Raymond > On 06/19/2010 01:38 PM, kille6525 wrote: >> Oh yah i just tried the valueOf(String string) and it made my program >> hate the two buttons one button caculates my two inputs and the other >> finishes but when i added that in it didnt like any of them. Weird >> >> On Jun 19, 9:05 am, Mikey wrote: >> >>> What was wrong with this: >>> >>> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html >>> >>> On 19 Jun 2010, at 17:02, kille6525 wrote: >>> >>> Ok since the EditText.getText. will only allow you to get a string i made a small program to get the string and convert it to a float. It was a pain to do. You could change the return to an int or double but i made this for floats... Here is the horrible code... >>> public float StringToFloat(String text) { //Used for the for loops int i = 0; //The number your go to return float number = 0; //Used to specify if your before the decimal or after int numtodec = 1; //Size of the int. 123.6 sizeofint = 3 int sizeofint = -1; //Gets the length of the String int size = text.length(); //Sets an array of characters equ to the string char string[] = text.toCharArray(); //Gets the size of the sizeofint and sizeofdec for(i = 0; i< size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } if(numtodec == 1) ++sizeofint; } //resets the num to dec numtodec = 1; //Stores the number for(i = 0; i< size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } int hold = string[i] - 48; double hold2; if(numtodec == 1) hold2 = java.lang.Math.pow(10.0,(double)(sizeofint - i)); else hold2 = java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); number += hold*hold2; } return number; } >>> -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. >>> NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android >>> To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en >> > > > -- > Raymond Rodgers > http://www.badlucksoft.com/ > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: StringToFloat code
I think he was specifically referring to the parseFloat() function... This is a direct link to a slightly different version of the api he referenced... http://java.sun.com/javase/7/docs/api/java/lang/Float.html#parseFloat(java.lang.String) Raymond On 06/19/2010 01:38 PM, kille6525 wrote: Oh yah i just tried the valueOf(String string) and it made my program hate the two buttons one button caculates my two inputs and the other finishes but when i added that in it didnt like any of them. Weird On Jun 19, 9:05 am, Mikey wrote: What was wrong with this: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html On 19 Jun 2010, at 17:02, kille6525 wrote: Ok since the EditText.getText. will only allow you to get a string i made a small program to get the string and convert it to a float. It was a pain to do. You could change the return to an int or double but i made this for floats... Here is the horrible code... public float StringToFloat(String text) { //Used for the for loops int i = 0; //The number your go to return float number = 0; //Used to specify if your before the decimal or after int numtodec = 1; //Size of the int. 123.6 sizeofint = 3 int sizeofint = -1; //Gets the length of the String int size = text.length(); //Sets an array of characters equ to the string char string[] = text.toCharArray(); //Gets the size of the sizeofint and sizeofdec for(i = 0; i< size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } if(numtodec == 1) ++sizeofint; } //resets the num to dec numtodec = 1; //Stores the number for(i = 0; i< size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } int hold = string[i] - 48; double hold2; if(numtodec == 1) hold2 = java.lang.Math.pow(10.0,(double)(sizeofint - i)); else hold2 = java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); number += hold*hold2; } return number; } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- Raymond Rodgers http://www.badlucksoft.com/ -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Saving contents of a Spinner with onSaveInstanceState
On Sat, Jun 19, 2010 at 1:36 PM, -DC- wrote: > I've got an app that uses a Spinner tied to an Adapter. I want to be > able to save its contents when onSaveInstanceState is called, but am > not sure which put method of the Bundle class I can use to do this? > > protected void onSaveInstanceState(Bundle outState) { > //TODO: Figure out how to save mDirectories (spinner) > outState.putString("mStatus", mStatus.getText().toString()); > outState.putString("mPath", mPath.getText().toString()); > // outState.putSerializable("mDirectories", mDirectories); <-- > Spinner object > outState.putStringArray("links", links); > outState.putInt("linksPointer", linksPointer); > super.onSaveInstanceState(outState); > } You do not want to put a Spinner in the onSaveInstanceState() Bundle. Besides the fact that it is impossible, doing so would cause your new activity to hold onto a reference to that Spinner, which holds onto a reference to your old activity, which will cause a substantial memory leak. Your Spinner's contents are set via some sort of Adapter. You should be making sure your new Activity can re-create that Adapter. Then, put either getItemSelectedId() or getItemSelectedPosition() in the Bundle, so you can restore the selection in the new Activity. -- Mark Murphy CommonsWare mmur...@commonsware.com http://commonsware.com -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: StringToFloat code
Oh yah i just tried the valueOf(String string) and it made my program hate the two buttons one button caculates my two inputs and the other finishes but when i added that in it didnt like any of them. Weird On Jun 19, 9:05 am, Mikey wrote: > What was wrong with this: > > http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html > > On 19 Jun 2010, at 17:02, kille6525 wrote: > > > Ok since the EditText.getText. will only allow you to get a string i > > made a small program to get the string and convert it to a float. It > > was a pain to do. You could change the return to an int or double but > > i made this for floats... > > Here is the horrible code... > > > public float StringToFloat(String text) > > { > > //Used for the for loops > > int i = 0; > > //The number your go to return > > float number = 0; > > //Used to specify if your before the decimal or after > > int numtodec = 1; > > //Size of the int. 123.6 sizeofint = 3 > > int sizeofint = -1; > > //Gets the length of the String > > int size = text.length(); > > //Sets an array of characters equ to the string > > char string[] = text.toCharArray(); > > //Gets the size of the sizeofint and sizeofdec > > for(i = 0; i < size; ++i) > > { > > if(string[i] == '.') > > { > > numtodec = 0; > > continue; > > } > > if(numtodec == 1) > > ++sizeofint; > > } > > //resets the num to dec > > numtodec = 1; > > //Stores the number > > for(i = 0; i < size; ++i) > > { > > if(string[i] == '.') > > { > > numtodec = 0; > > continue; > > } > > int hold = string[i] - 48; > > double hold2; > > if(numtodec == 1) > > hold2 = > > java.lang.Math.pow(10.0,(double)(sizeofint - i)); > > else > > hold2 = > > java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); > > number += hold*hold2; > > } > > return number; > > } > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Beginners" group. > > > NEW! Try asking and tagging your question on Stack Overflow at > >http://stackoverflow.com/questions/tagged/android > > > To unsubscribe from this group, send email to > > android-beginners+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Saving contents of a Spinner with onSaveInstanceState
I've got an app that uses a Spinner tied to an Adapter. I want to be able to save its contents when onSaveInstanceState is called, but am not sure which put method of the Bundle class I can use to do this? protected void onSaveInstanceState(Bundle outState) { //TODO: Figure out how to save mDirectories (spinner) outState.putString("mStatus", mStatus.getText().toString()); outState.putString("mPath", mPath.getText().toString()); //outState.putSerializable("mDirectories", mDirectories); <-- Spinner object outState.putStringArray("links", links); outState.putInt("linksPointer", linksPointer); super.onSaveInstanceState(outState); } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: StringToFloat code
There is no string to float function to do it for you. Now i dont have it to where it will check for a negative or positive sign but in my app there is none for now... On Jun 19, 9:05 am, Mikey wrote: > What was wrong with this: > > http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html > > On 19 Jun 2010, at 17:02, kille6525 wrote: > > > Ok since the EditText.getText. will only allow you to get a string i > > made a small program to get the string and convert it to a float. It > > was a pain to do. You could change the return to an int or double but > > i made this for floats... > > Here is the horrible code... > > > public float StringToFloat(String text) > > { > > //Used for the for loops > > int i = 0; > > //The number your go to return > > float number = 0; > > //Used to specify if your before the decimal or after > > int numtodec = 1; > > //Size of the int. 123.6 sizeofint = 3 > > int sizeofint = -1; > > //Gets the length of the String > > int size = text.length(); > > //Sets an array of characters equ to the string > > char string[] = text.toCharArray(); > > //Gets the size of the sizeofint and sizeofdec > > for(i = 0; i < size; ++i) > > { > > if(string[i] == '.') > > { > > numtodec = 0; > > continue; > > } > > if(numtodec == 1) > > ++sizeofint; > > } > > //resets the num to dec > > numtodec = 1; > > //Stores the number > > for(i = 0; i < size; ++i) > > { > > if(string[i] == '.') > > { > > numtodec = 0; > > continue; > > } > > int hold = string[i] - 48; > > double hold2; > > if(numtodec == 1) > > hold2 = > > java.lang.Math.pow(10.0,(double)(sizeofint - i)); > > else > > hold2 = > > java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); > > number += hold*hold2; > > } > > return number; > > } > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Beginners" group. > > > NEW! Try asking and tagging your question on Stack Overflow at > >http://stackoverflow.com/questions/tagged/android > > > To unsubscribe from this group, send email to > > android-beginners+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Re: Comparing data retrieved from SQL query
And just as safe method for avoiding NPE, its good practice to do the following... if("text".equals(queryString)) //do stuff On Fri, Jun 18, 2010 at 10:50 AM, Tollas wrote: > Worked great! Thanks! > > On Jun 18, 11:12 am, Justin Anderson wrote: > > You cannot use == for comparing strings. You have to use the equals > method: > > > > if (queryString.equals("text")) > > //do stuff > > > > -- > > There are only 10 types of people in the world... > > Those who know binary and those who don't. > > -- > > > > On Fri, Jun 18, 2010 at 9:57 AM, Tollas wrote: > > > I am retrieving data from a SQL query. The data retrieves fine. If I > > > place the data in a TextView field, I see the text. > > > When I try to compare it in an "IF" statement, however, the statement > > > sees the data as false, even if it should be true. > > > If I set the variable to a good value (not getting data from the SQL > > > query) the IF statement works fine. > > > > > Example > > > > > String queryString = c.getString(c.getColumnIndex("table_query")); > > > > > if (queryString == "text"){ > > > // do this > > > } > > > > > I have checked my data. If I query the database for table_query = > > > 'text' I receive results. > > > This is happening for 5 different fields where a comparison is made, > > > each with a different variable and if statement. > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Beginners" group. > > > > > NEW! Try asking and tagging your question on Stack Overflow at > > >http://stackoverflow.com/questions/tagged/android > > > > > To unsubscribe from this group, send email to > > > android-beginners+unsubscr...@googlegroups.com > > > > > > For more options, visit this group at > > >http://groups.google.com/group/android-beginners?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- Mahesh http://www.maheshdixit.com http://askmahesh.blogspot.com/ -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] StringToFloat code
What was wrong with this: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html On 19 Jun 2010, at 17:02, kille6525 wrote: > Ok since the EditText.getText. will only allow you to get a string i > made a small program to get the string and convert it to a float. It > was a pain to do. You could change the return to an int or double but > i made this for floats... > Here is the horrible code... > > >public float StringToFloat(String text) >{ > //Used for the for loops >int i = 0; > //The number your go to return >float number = 0; > //Used to specify if your before the decimal or after >int numtodec = 1; > //Size of the int. 123.6 sizeofint = 3 >int sizeofint = -1; > //Gets the length of the String >int size = text.length(); > //Sets an array of characters equ to the string >char string[] = text.toCharArray(); > //Gets the size of the sizeofint and sizeofdec >for(i = 0; i < size; ++i) >{ >if(string[i] == '.') >{ >numtodec = 0; >continue; >} > if(numtodec == 1) > ++sizeofint; >} > //resets the num to dec >numtodec = 1; > //Stores the number >for(i = 0; i < size; ++i) >{ >if(string[i] == '.') >{ >numtodec = 0; >continue; >} > int hold = string[i] - 48; > double hold2; > if(numtodec == 1) > hold2 = > java.lang.Math.pow(10.0,(double)(sizeofint - i)); > else > hold2 = > java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); > number += hold*hold2; >} >return number; >} > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] StringToFloat code
Ok since the EditText.getText. will only allow you to get a string i made a small program to get the string and convert it to a float. It was a pain to do. You could change the return to an int or double but i made this for floats... Here is the horrible code... public float StringToFloat(String text) { //Used for the for loops int i = 0; //The number your go to return float number = 0; //Used to specify if your before the decimal or after int numtodec = 1; //Size of the int. 123.6 sizeofint = 3 int sizeofint = -1; //Gets the length of the String int size = text.length(); //Sets an array of characters equ to the string char string[] = text.toCharArray(); //Gets the size of the sizeofint and sizeofdec for(i = 0; i < size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } if(numtodec == 1) ++sizeofint; } //resets the num to dec numtodec = 1; //Stores the number for(i = 0; i < size; ++i) { if(string[i] == '.') { numtodec = 0; continue; } int hold = string[i] - 48; double hold2; if(numtodec == 1) hold2 = java.lang.Math.pow(10.0,(double)(sizeofint - i)); else hold2 = java.lang.Math.pow(10.0,(double)(sizeofint+1 - i)); number += hold*hold2; } return number; } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Layout Tabhost with Header?
Thanks Mark, When I tried nesting inside a layout I got a null pointer exception. I was convinced that the TabHost could not be used within another layout (maybe I was wrong). I figured out a different solution - I replaced the title bar entirely. This is ultimately a better solution for what I was trying to do. j On Sat, Jun 19, 2010 at 10:35 AM, Mark Murphy wrote: > On Sat, Jun 19, 2010 at 10:25 AM, Jason Van Anden > wrote: > > Can someone tell me if its possible to add a header layout over tabs in > > 1.5? If so, how? > > Put the TabHost within another layout. > > > When I attempt to nest a TabHost within another layout - > > things go terribly wrong. > > It is difficult to help you without more details about "terribly wrong". > > -- > Mark Murphy > CommonsWare > mmur...@commonsware.com > http://commonsware.com > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Layout Tabhost with Header?
On Sat, Jun 19, 2010 at 10:25 AM, Jason Van Anden wrote: > Can someone tell me if its possible to add a header layout over tabs in > 1.5? If so, how? Put the TabHost within another layout. > When I attempt to nest a TabHost within another layout - > things go terribly wrong. It is difficult to help you without more details about "terribly wrong". -- Mark Murphy CommonsWare mmur...@commonsware.com http://commonsware.com -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Layout Tabhost with Header?
Hi All, Can someone tell me if its possible to add a header layout over tabs in 1.5? If so, how? When I attempt to nest a TabHost within another layout - things go terribly wrong. Thanks, i++ -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] LIVE SEX CAMS ! http://www.LiveHappyStrip.com
LIVE SEX CAMS ! http://www.LiveHappyStrip.com -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Local TCP/IP server
On Sat, Jun 19, 2010 at 8:31 AM, Alessandro Pellizzari wrote: > before I start banging my head against the wall, I would like to know if > the software I have in mind is technically possible on Android. > > I would like to code a local tcp/ip server, listening on an high port > (say... 8080 or 12345) only on the localhost interface (127.0.0.1). > Is it possibile? Sure. In this area, Android works pretty similar to standard Java. > And also, is it possible to start my "service provider" automatically > whenever some app tries to connect to that port (via a notification, for > example)? There is no equivalent of inetd or xinetd for Android SDK applications, if you are thinking of something like those Linux daemons. > Or must I start my server everytime I need it, manually? For some definition of "manually", yes. The service will need to be running to serve data over your port. Bear in mind that there is probably a better solution for whatever business problem you are trying to solve with a localhost-only TCP server. -- Mark Murphy CommonsWare mmur...@commonsware.com http://commonsware.com -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Local TCP/IP server
Hi all, before I start banging my head against the wall, I would like to know if the software I have in mind is technically possible on Android. I would like to code a local tcp/ip server, listening on an high port (say... 8080 or 12345) only on the localhost interface (127.0.0.1). Is it possibile? I found near to nothing on the Internet. And also, is it possible to start my "service provider" automatically whenever some app tries to connect to that port (via a notification, for example)? Or must I start my server everytime I need it, manually? Thank you very much. Bye. -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en