I am trying to create a simple program that extracts a small random number and displays it to the user in text form. After finally getting a random number to generate (I think) the program throws a fatal exception whenever I run. There are no errors in the code, but I am a complete beginner, and I start just so that I can learn. A few hours later I asked for help. I am almost sure that my fragment of random numbers is in the wrong place, I just don’t know where to put it. Everywhere I tried, I get the same error.
This is .java
package com.eai.vgp; import java.util.Random; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) {
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> </RelativeLayout>
Logcat
03-03 16:34:25.313: I/Process(740): Sending signal. PID: 740 SIG: 9 03-03 16:35:02.212: E/Trace(806): error opening trace file: No such file or directory (2) 03-03 16:35:02.802: W/ResourceType(806): No package identifier when getting value for resource number 0x00000001 03-03 16:35:02.813: D/AndroidRuntime(806): Shutting down VM 03-03 16:35:02.813: W/dalvikvm(806): threadid=1: thread exiting with uncaught exception (group=0x40a13300) 03-03 16:35:02.833: E/AndroidRuntime(806): FATAL EXCEPTION: main 03-03 16:35:02.833: E/AndroidRuntime(806): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eai.vgp/com.eai.vgp.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID
android random exception textview
Eric Anthony Mar 03 '13 at 21:26 2013-03-03 21:26
source share