[android-developers] Re: EditText.getText() not working
using findViewById() 81 times seems more demanding than creating them at runtime to me. There is always an Exception thrown if your app is crashing, look at the logcat in the 'DDMS' view in Eclipse. If you only see a runtime exception then you need to get the cause from the exception. Surround the call with a try-catch and use something like this: catch (Exception e) { final static String TAG = "you app name"; StackTraceElement[] arr = e.getStackTrace(); for (int i=0; i wrote: > I have tried doing the EditTexts programatically in a loop. No luck. > Still gives me the same problem. I am having a hard time trying to > figure out what the exact problem is. I am new to the eclipse IDE and > the android programming. > > On Jan 9, 12:31 am, TreKing wrote: > > > > Now when I try to do a simple getText() method on textArray[][], it > > > gives me a runtime error but setText() method works fine on textArray[] > > > [] > > > What's the error? Are you checking for null? > > > Also, are you seriously defining 81 objects in your layout and then finding > > each one by ID? > > Why don't you generate your EditTexts programmatically in a double loop? > > > --- > > -- > > TreKing - Chicago transit tracking app for Android-powered > > deviceshttp://sites.google.com/site/rezmobileapps/treking > > > On Fri, Jan 8, 2010 at 11:08 AM, zosq wrote: > > > I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as > > > shown below. > > > > > > > > > > xmlns:android="http://schemas.android.com/apk/res/android"; > > > android:layout_width="fill_parent" > > > android:layout_height="wrap_content" > > > android:background="@color/activity_background"> > > > > > android:id="@+id/text1" > > > android:layout_width="33dip" > > > android:layout_height="33dip" > > > android:background="@color/textBox_background" > > > android:layout_marginBottom="2dip" > > > android:layout_marginRight="2dip" > > > android:layout_marginLeft="2dip" > > > android:maxLength="1" > > > android:textColor="@color/textBox_color" > > > android:numeric="integer" > > > android:paddingLeft="11dip" > > > android:selectAllOnFocus="true" /> > > > > > android:id="@+id/text2" > > > android:layout_width="33dip" > > > android:layout_height="33dip" > > > android:background="@color/textBox_background" > > > android:layout_marginBottom="2dip" > > > android:layout_marginRight="2dip" > > > android:maxLength="1" > > > android:textColor="@color/textBox_color" > > > android:numeric="integer" > > > android:paddingLeft="11dip" > > > android:layout_toRightOf="@id/text1" > > > android:layout_alignTop="@id/text1" > > > android:selectAllOnFocus="true" /> > > > > > android:id="@+id/text3" > > > android:layout_width="33dip" > > > android:layout_height="33dip" > > > android:background="@color/textBox_background" > > > android:layout_marginBottom="2dip" > > > android:layout_marginRight="4dip" > > > android:maxLength="1" > > > android:textColor="@color/textBox_color" > > > android:numeric="integer" > > > android:paddingLeft="11dip" > > > android:layout_toRightOf="@id/text2" > > > android:layout_alignTop="@id/text1" > > > android:selectAllOnFocus="true" /> > > > > > android:id="@+id/text4" > > > android:layout_width="33dip" > > > android:layout_height="33dip" > > > android:background="@color/textBox_background" > > > android:layout_marginBottom="2dip" > > > android:layout_marginRight="2dip" > > > android:maxLength="1" > > > android:textColor="@color/textBox_color" > > > android:numeric="integer" > > > android:paddingLeft="11dip" > > > android:layout_toRightOf="@id/text3" > > > android:layout_alignTop="@id/text1" > > > android:selectAllOnFocus="true" /> > > > > > android:id="@+id/text5" > > > android:layout_width="33dip" > > > android:layout_height="33dip" > > > android:background="@color/textBox_background" > > > android:layout_marginBottom="2dip" > > > android:layout_marginRight="2dip" > > > android:maxLength="1" > > > android:textColor="@color/
[android-developers] Re: EditText.getText() not working
I have tried doing the EditTexts programatically in a loop. No luck. Still gives me the same problem. I am having a hard time trying to figure out what the exact problem is. I am new to the eclipse IDE and the android programming. On Jan 9, 12:31 am, TreKing wrote: > > Now when I try to do a simple getText() method on textArray[][], it > > gives me a runtime error but setText() method works fine on textArray[] > > [] > > What's the error? Are you checking for null? > > Also, are you seriously defining 81 objects in your layout and then finding > each one by ID? > Why don't you generate your EditTexts programmatically in a double loop? > > --- > -- > TreKing - Chicago transit tracking app for Android-powered > deviceshttp://sites.google.com/site/rezmobileapps/treking > > > > On Fri, Jan 8, 2010 at 11:08 AM, zosq wrote: > > I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as > > shown below. > > > > > > > xmlns:android="http://schemas.android.com/apk/res/android"; > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:background="@color/activity_background"> > > > android:id="@+id/text1" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:layout_marginLeft="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text2" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text1" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text3" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="4dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text2" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text4" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text3" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text5" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text4" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text6" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="4dip" > > android:maxLength="1" > > android:textCol
[android-developers] Re: EditText.getText() not working
Thanks for the reply, but that doesn't answer my question. On Jan 9, 9:15 am, Sasikumar S wrote: > http://www.androidpeople.com/category/edittext/ > > see this... > > On Jan 8, 10:08 pm, zosq wrote: > > > > > I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as > > shown below. > > > > > > > xmlns:android="http://schemas.android.com/apk/res/android"; > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:background="@color/activity_background"> > > > android:id="@+id/text1" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:layout_marginLeft="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text2" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text1" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text3" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="4dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text2" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text4" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text3" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text5" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text4" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text6" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="4dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text5" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text7" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > >
[android-developers] Re: EditText.getText() not working
Yes I did check for null. It is not the null exception. I am having problems finding out what kind of an error it is. There is no error in the code. The program stops in the middle while running. "Why don't you generate your EditTexts programmatically in a double loop?" That is a good idea but I was going through the documentation and it was suggested that we use the xml for doing the GUI. Though the 81 objects can be dynamically generated wouldn't that make the app slower? Well anyway, I will try doing that dynamically and see if that fixes my problem. Thank you for the reply. On Jan 9, 12:31 am, TreKing wrote: > > Now when I try to do a simple getText() method on textArray[][], it > > gives me a runtime error but setText() method works fine on textArray[] > > [] > > What's the error? Are you checking for null? > > Also, are you seriously defining 81 objects in your layout and then finding > each one by ID? > Why don't you generate your EditTexts programmatically in a double loop? > > --- > -- > TreKing - Chicago transit tracking app for Android-powered > deviceshttp://sites.google.com/site/rezmobileapps/treking > > > > On Fri, Jan 8, 2010 at 11:08 AM, zosq wrote: > > I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as > > shown below. > > > > > > > xmlns:android="http://schemas.android.com/apk/res/android"; > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:background="@color/activity_background"> > > > android:id="@+id/text1" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:layout_marginLeft="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text2" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text1" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text3" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="4dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text2" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text4" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text3" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@+id/text5" > > android:layout_width="33dip" > > android:layout_height="33dip" > > android:background="@color/textBox_background" > > android:layout_marginBottom="2dip" > > android:layout_marginRight="2dip" > > android:maxLength="1" > > android:textColor="@color/textBox_color" > > android:numeric="integer" > > android:paddingLeft="11dip" > > android:layout_toRightOf="@id/text4" > > android:layout_alignTop="@id/text1" > > android:selectAllOnFocus="true" /> > > > android:id="@
[android-developers] Re: EditText.getText() not working
http://www.androidpeople.com/category/edittext/ see this... On Jan 8, 10:08 pm, zosq wrote: > I am simple sudoku app. My main.xml has 81 EditText and 2 buttons as > shown below. > > > > xmlns:android="http://schemas.android.com/apk/res/android"; > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:background="@color/activity_background"> > android:id="@+id/text1" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="2dip" > android:layout_marginLeft="2dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:selectAllOnFocus="true" /> > android:id="@+id/text2" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="2dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text1" > android:layout_alignTop="@id/text1" > android:selectAllOnFocus="true" /> > android:id="@+id/text3" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="4dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text2" > android:layout_alignTop="@id/text1" > android:selectAllOnFocus="true" /> > android:id="@+id/text4" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="2dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text3" > android:layout_alignTop="@id/text1" > android:selectAllOnFocus="true" /> > android:id="@+id/text5" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="2dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text4" > android:layout_alignTop="@id/text1" > android:selectAllOnFocus="true" /> > android:id="@+id/text6" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="4dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text5" > android:layout_alignTop="@id/text1" > android:selectAllOnFocus="true" /> > android:id="@+id/text7" > android:layout_width="33dip" > android:layout_height="33dip" > android:background="@color/textBox_background" > android:layout_marginBottom="2dip" > android:layout_marginRight="2dip" > android:maxLength="1" > android:textColor="@color/textBox_color" > android:numeric="integer" > android:paddingLeft="11dip" > android:layout_toRightOf="@id/text6" > android:layout_alignTop="@id/text1" > android:selec