Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A few things I can think of. </p> <p>First, Your RelativeLayout has no relative positioning information. I would assume you meant to put this in a LinearLayout with orientation set to vertical from what you describe. My guess is that the list is not actually being drawn since it isn't even anchored to anything in the current RelativeLayout. If you stick with the RelativeLayout, make sure to put an id on the app_name TextView and position the ListView under it via layout_below.</p> <p><strong>LinearLayout Solution</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:text="@string/app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt;&lt;/TextView&gt; &lt;ListView android:id="@+id/selectView" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>RelativeLayout Solution:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:id="@+id/app_name_text" android:text="@string/app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" &gt;&lt;/TextView&gt; &lt;ListView android:id="@+id/selectView" android:layout_below="@id/app_name_text" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Next, your getView() returns the same textView for all 3 indexes. It's not a problem to display the same view over multiple indexes however with a list size of three, I am betting that the screen can display all three at the same time. And since a View can't be in more than one position at a time, I actually would expect this to fail so I doubt it is even getting to this code yet. Try creating a new TextView for each getView(). Also your MockTextView doesn't have layout params of it's own. So laying it out within a listView cell might not be happening either. So you can give it params of type AbsListView.LayoutParams(WRAP_CONTENT, WRAP_CONTENT). Again though I would expect this to error if it got to the original code.</p> <p><strong>getView() tidy up:</strong></p> <pre><code> @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { TextView textView = new TextView(parent.getContext()); textView.setText("Position is:"+position); textView.setBackgroundColor(Color.CYAN); textView.setLayoutParams(new AbsListView.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); convertView = textView; } return mMockTextView; } </code></pre> <p>And lastly the wrap_content height of your list can sometimes be problematic. I am not aware of all the scenarios. If you end up changing to a LinearLayout try setting your layout_height of the list view to 0 and then set the layout_weight=1. This forces the linear layout to inflate it into more space.</p> <p><strong>LinearLayout Weight Solution:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:text="@string/app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt;&lt;/TextView&gt; &lt;ListView android:id="@+id/selectView" android:layout_weight="1" android:layout_height="0dp" android:layout_width="wrap_content"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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