Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListActivity Scrollview How to get a list to scroll
    text
    copied!<p>I was going through a tutorial on <a href="http://www.vogella.de/articles/AndroidListView/article.html" rel="nofollow">http://www.vogella.de/articles/AndroidListView/article.html</a> learning how to do use ListActivity. I am trying to get the list to scroll, but came to realize that you can't use scrollview in the layout file to make this happen. After googling around, I realized that android doesn't allow this, but I haven't been able to find an answer that seems to explain how to make the scrolling happen. </p> <p>The code is below:</p> <pre><code>public class MyListActivityActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" , "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; /*LayoutInflater factory = getLayoutInflater(); LinearLayout footer = (LinearLayout) factory.inflate(R.layout.main, null); getListView().addFooterView(footer); */ ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.rowlayout, R.id.label, values); setListAdapter(adapter); } protected void onListItemClick(ListView l, View v, int position, long id) { String item = (String) getListAdapter().getItem(position); Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show(); } } </code></pre> <p>//The xml file: </p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;ImageView android:id="@+id/icon" android:layout_width="22px" android:layout_height="22px" android:layout_marginLeft="4px" android:layout_marginRight="10px" android:layout_marginTop="4px" android:src="@drawable/ic_launcher" &gt; &lt;/ImageView&gt; &lt;TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:textSize="20px" &gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>Currently, the more values you put into the array, the smaller the list becomes to make sure that it fits on the screen. I want the text to stay the same size and let it be a long list that I could scroll through.</p> <p>I've read somewhere about addHeader and addFooter that'd enable the scrolling to happen. But can anyone explain to me or lead me to a source that has more information about how to implement this? </p> <p>I'd appreciate any input. Thanks</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