I’m VERY new to android programming, so please forgive.
I have an assignment in which I need to add a text box to the xml of the current codebase and then change a variable in the code when the user edits the text box.
So I added the text box, and it’s showing up fine, but when I try to initialize it I get an error that the app has stopped unexpectedly and a bunch of stuff in LogCat.
CLARIFICATION: only the last textbox, intersymboltime, causes the errors. If I comment out its initialization everything runs fine.
a sample of my xml (first two are from the existing code, for comparison):
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/hostText"
android:layout_marginTop="5dp"
android:text="@string/portlabel"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/portText"
android:layout_width="110dp"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView3"
android:hint="@string/portHint"
android:inputType="number|textNoSuggestions" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/portText"
android:layout_marginTop="14dp"
android:text="@string/symboltime" />
<EditText
android:id="@+id/intersymboltime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView4"
android:ems="10"
android:hint="@string/symboltimehint"
android:inputType="number" />
in my onCreate (first two calls are in existing code, for comparison):
((TextView)findViewById(R.id.hostText)).setText(mServerHost);
((TextView)findViewById(R.id.portText)).setText(new Integer(mServerPort).toString());
((TextView)findViewById(R.id.intersymboltime)).setText(mClient.portToIntersymbolTime(mServerPort, 1));
portToIntersymbolTime returns as expected.
what am I missing?!
EDIT: my logcat logs:
04-13 18:10:17.556: W/ResourceType(716): No package identifier when getting value for resource number 0x00000100
04-13 18:10:17.566: D/AndroidRuntime(716): Shutting down VM
04-13 18:10:17.566: W/dalvikvm(716): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-13 18:10:17.576: E/AndroidRuntime(716): FATAL EXCEPTION: main
04-13 18:10:17.576: E/AndroidRuntime(716): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.uw.cs.cse461.sp12.timingframing/edu.uw.cs.cse461.sp12.timingframing.TimingFramingAndroidActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x100
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.os.Handler.dispatchMessage(Handler.java:99)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.os.Looper.loop(Looper.java:123)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-13 18:10:17.576: E/AndroidRuntime(716): at java.lang.reflect.Method.invokeNative(Native Method)
04-13 18:10:17.576: E/AndroidRuntime(716): at java.lang.reflect.Method.invoke(Method.java:507)
04-13 18:10:17.576: E/AndroidRuntime(716): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-13 18:10:17.576: E/AndroidRuntime(716): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-13 18:10:17.576: E/AndroidRuntime(716): at dalvik.system.NativeStart.main(Native Method)
04-13 18:10:17.576: E/AndroidRuntime(716): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x100
04-13 18:10:17.576: E/AndroidRuntime(716): at android.content.res.Resources.getText(Resources.java:201)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.widget.TextView.setText(TextView.java:2857)
04-13 18:10:17.576: E/AndroidRuntime(716): at edu.uw.cs.cse461.sp12.timingframing.TimingFramingAndroidActivity.onCreate(TimingFramingAndroidActivity.java:39)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-13 18:10:17.576: E/AndroidRuntime(716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-13 18:10:17.576: E/AndroidRuntime(716): … 11 more
Posting your logcat would help narrow it down for sure. The first place I would look is what is the return type of
mClient.portToIntersymbolTime(mServerPort, 1). EditText requires typeCharSequence. I am sure you need to use.toStringor something like that.