Note that there are some explanatory texts on larger screens.

plurals
  1. POSet visibility of TextView in android not working
    text
    copied!<p>My program runs into a runtime exception when I try to make the view 'GONE'. My code that handles it:</p> <pre><code>setContentView(R.layout.list_main); ... lv = getListView(); View header = (View) findViewById(R.id.header_layout_root); TextView tv = (TextView) header.findViewById(R.id.new_highscore); tv.setVisibility(View.GONE); lv = getListView(); LayoutInflater inflater = getLayoutInflater(); View header = inflater.inflate(R.layout.list_header, (ViewGroup) findViewById(R.id.header_layout_root)); lv.addHeaderView(header, null, false); mC = mDBHelper.getAllHighScores(); startManagingCursor(mC); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.row, mC, new String[] { DBAdapter.COL_NAME, DBAdapter.COL_SCORE }, new int[] { R.id.txtText1, R.id.txtText2 }); lv.setAdapter(adapter); </code></pre> <p>xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/header_layout_root" android:background="#ffffff" android:orientation="vertical"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Pick Master High Scores" android:background="#000000" android:textColor="#ffffff" android:textSize="28dp" android:gravity="center_horizontal" android:paddingTop="10dp" android:paddingBottom="10dp"&gt; &lt;/TextView&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/header_layout_root1"&gt; &lt;ImageView android:id="@+id/sample_image" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:src="@drawable/pickmaster" android:scaleType="fitXY"&gt; &lt;/ImageView&gt; &lt;TextView android:id="@+id/new_highscore" android:text="New High Score added!" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffffff" android:textSize="12dp" android:background="#AA000000" android:padding="5dp" android:layout_alignParentLeft="true" android:layout_alignBottom="@id/sample_image"&gt; &lt;/TextView&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p> <p>The problem is, I think, that new_highscore is not in list_main, but it is in another xml file. I am using two as I have a listview with a header and image etc.</p> <p>Any ideas on making the view 'invisible' or just 'gone'?</p> <p>Thanks,</p> <p>Ben</p>
 

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