Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid position crashes app
    primarykey
    data
    text
    <p>This is the XML that I have:</p> <p> </p> <pre><code>&lt;ImageView android:id="@+id/ivRockPic" android:layout_width="230dp" android:layout_height="230dp" android:layout_gravity="center" android:background="@drawable/image_border" /&gt; &lt;TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="100" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:weightSum="100" android:id="@+id/llAns1" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/tvAns1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:text="Ans1" android:textSize="20sp" android:textStyle="bold" /&gt; &lt;ImageView android:id="@+id/ivAns1" android:layout_gravity="right" android:layout_weight="50" android:layout_width="100dp" android:layout_height="50dp" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:weightSum="100" android:id="@+id/llAns2" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/tvAns2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Ans2" android:layout_weight="50" android:textSize="20sp" android:textStyle="bold" /&gt; &lt;ImageView android:id="@+id/ivAns2" android:layout_gravity="right" android:layout_width="100dp" android:layout_weight="50" android:layout_height="50dp" /&gt; &lt;/LinearLayout&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="100" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:weightSum="100" android:id="@+id/llAns3" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/tvAns3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:text="Ans3" android:textSize="20sp" android:textStyle="bold" /&gt; &lt;ImageView android:id="@+id/ivAns3" android:layout_gravity="right" android:layout_width="100dp" android:layout_weight="50" android:layout_height="50dp" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:weightSum="100" android:id="@+id/llAns4" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/tvAns4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:text="Ans4" android:textSize="20sp" android:textStyle="bold" /&gt; &lt;ImageView android:id="@+id/ivAns4" android:layout_gravity="right" android:layout_width="100dp" android:layout_weight="50" android:layout_height="50dp" /&gt; &lt;/LinearLayout&gt; &lt;/TableRow&gt; &lt;TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="100" &gt; &lt;TextView android:id="@+id/tvAnswer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" /&gt; &lt;Button android:id="@+id/bNext" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="50" android:text="Next" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p></p> <p>Just posted one button. And this repeats. This set up works perfectly fine. Tested, initialized in the bean, it is working. But here is the issue, when I move the ImageView above the TextView, it throws me an error on the initiation line of the view where I fetch the ImageView id. But when I move it back, it works fine. Any ideas?</p> <p>Error:</p> <p>The two method inside are just initializations of strings:</p> <pre><code>res = getResources(); img = (ImageView)findViewById(R.id.ivRockPic); tvAnswer = (TextView) findViewById(R.id.tvAnswer); initializeRussian(); initAnswerList(); next = (Button)findViewById(R.id.bNext); iViews[0] = (ImageView) findViewById(R.id.ivAns1);//dies iViews[1] = (ImageView) findViewById(R.id.ivAns2); iViews[2] = (ImageView) findViewById(R.id.ivAns3); iViews[3] = (ImageView) findViewById(R.id.ivAns4); lLayouts[0] = (LinearLayout) findViewById(R.id.llAns1); lLayouts[1] = (LinearLayout) findViewById(R.id.llAns2); lLayouts[2] = (LinearLayout) findViewById(R.id.llAns3); lLayouts[3] = (LinearLayout) findViewById(R.id.llAns4); tViews[0] = (TextView) findViewById(R.id.tvAns1); tViews[1] = (TextView) findViewById(R.id.tvAns2); tViews[2] = (TextView) findViewById(R.id.tvAns3); tViews[3] = (TextView) findViewById(R.id.tvAns4); 06-29 23:57:09.838: E/AndroidRuntime(5236): Uncaught handler: thread main exiting due to uncaught exception 06-29 23:57:09.869: E/AndroidRuntime(5236): java.lang.RuntimeException: Unable to start activity ComponentInfo{rock.school.rzn.rockquiz/rock.school.rzn.rockquiz.GameScreen}: java.lang.ClassCastException: android.widget.TextView 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.os.Handler.dispatchMessage(Handler.java:99) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.os.Looper.loop(Looper.java:123) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread.main(ActivityThread.java:4363) 06-29 23:57:09.869: E/AndroidRuntime(5236): at java.lang.reflect.Method.invokeNative(Native Method) 06-29 23:57:09.869: E/AndroidRuntime(5236): at java.lang.reflect.Method.invoke(Method.java:521) 06-29 23:57:09.869: E/AndroidRuntime(5236): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 06-29 23:57:09.869: E/AndroidRuntime(5236): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 06-29 23:57:09.869: E/AndroidRuntime(5236): at dalvik.system.NativeStart.main(Native Method) 06-29 23:57:09.869: E/AndroidRuntime(5236): Caused by: java.lang.ClassCastException: android.widget.TextView 06-29 23:57:09.869: E/AndroidRuntime(5236): at rock.school.rzn.rockquiz.GameScreen.initialize(GameScreen.java:171) 06-29 23:57:09.869: E/AndroidRuntime(5236): at rock.school.rzn.rockquiz.GameScreen.onCreate(GameScreen.java:47) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 06-29 23:57:09.869: E/AndroidRuntime(5236): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 06-29 23:57:09.869: E/AndroidRuntime(5236): ... 11 more </code></pre>
    singulars
    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.
    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