Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplay text value on EditText on run time
    primarykey
    data
    text
    <p>I'm a novice in java and android development. I'm developing this very basic 4x4 sudoku app wherein m trying to display some text values based on the game number. However, at run time the text in the EditText field displays blank.</p> <p><strong>Below is the code in onCreate()</strong></p> <pre><code> a=gamenumber(); //returns a random game number displayrandommatrix(a); findviewbyidfunc(); </code></pre> <p><strong>Below is the sample code for displaying values in EditText</strong></p> <pre><code> public void displayrandommatrix(int n) { switch(n) { case 1: r11.setText("2"); r12.setText("3"); r23.setText("3"); r24.setText("2"); r32.setText("4"); r33.setText("2"); r41.setText("1"); r44.setText("3"); break; case 2: r12.setText("2"); r13.setText("4"); r21.setText("1"); r24.setText("3"); r31.setText("4"); r34.setText("2"); r42.setText("1"); r43.setText("3"); break; } </code></pre> <p><strong>This is the code I'm using for random game number.</strong></p> <pre><code> public int gamenumber() { int b=randint.charAt(r.nextInt(randint.length())); return b; } public void findviewbyidfunc() { checksol=(Button)findViewById(R.id.checksol1); r11=(EditText)findViewById(R.id.row1col1); r21=(EditText)findViewById(R.id.row2col1); r31=(EditText)findViewById(R.id.row3col1); r41=(EditText)findViewById(R.id.row4col1); } </code></pre> <p><strong>List of Logcat errors:</strong> 10-21 06:15:12.564: E/AndroidRuntime(1467): FATAL EXCEPTION: main 10-21 06:15:12.564: E/AndroidRuntime(1467): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sudokunew/com.example.sudokunew.Level2_play}: java.lang.NullPointerException 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread.access$600(ActivityThread.java:141) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.os.Handler.dispatchMessage(Handler.java:99) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.os.Looper.loop(Looper.java:137) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread.main(ActivityThread.java:5103) 10-21 06:15:12.564: E/AndroidRuntime(1467): at java.lang.reflect.Method.invokeNative(Native Method) 10-21 06:15:12.564: E/AndroidRuntime(1467): at java.lang.reflect.Method.invoke(Method.java:525) 10-21 06:15:12.564: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 10-21 06:15:12.564: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-21 06:15:12.564: E/AndroidRuntime(1467): at dalvik.system.NativeStart.main(Native Method) 10-21 06:15:12.564: E/AndroidRuntime(1467): Caused by: java.lang.NullPointerException 10-21 06:15:12.564: E/AndroidRuntime(1467): at com.example.sudokunew.Level2_play.displayrandommatrix(Level2_play.java:177) 10-21 06:15:12.564: E/AndroidRuntime(1467): at com.example.sudokunew.Level2_play.onCreate(Level2_play.java:26) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.Activity.performCreate(Activity.java:5133) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 10-21 06:15:12.564: E/AndroidRuntime(1467): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 10-21 06:15:12.564: E/AndroidRuntime(1467): ... 11 more</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload