Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid App Null Pointer on Specific Textview
    primarykey
    data
    text
    <p>Normally null pointer exceptions seem to be view related - where the wrong layout is targeted.</p> <p>This is different I reckon. I have four textviews in a layout and one returns a null, the rest work fine. Here is the layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello" /&gt; &lt;TextView android:id="@+id/text2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="stringello2" /&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="ip" android.id="@+id/iptest" /&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hostname" android:id="@+id/hostname" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And here is the test code:</p> <pre><code>public class MainActivity extends Activity { /** Called when the activity is first created. */ protected TextView text; protected TextView ip; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); text = (TextView) findViewById(R.id.text); text.setText("goodbye"); text = (TextView) findViewById(R.id.hostname); text.setText("hostname flibble"); // text = (TextView) findViewById(R.id.text2); text = (TextView) findViewById(R.id.iptest); text.setText("ip flibble"); } } </code></pre> <p>If I switch the comment to the other textview, it works fine. If I target <code>iptest</code> it returns null and raises an exception.</p> <p>Any ideas why? All four appear in <code>gen</code> and they all reappear if I delete <code>gen</code> and recompile.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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