Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You Should not have a listview within a ScrollView.</p> <p>But you can have a custom class and use that to accomplish A Listview with in a ScrollView.</p> <p>Try the following code</p> <p>first make a custom ScrollView Class.</p> <pre><code>public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: return false; default: break; } return false; } @Override public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); return true; } } </code></pre> <p>Then use this class for you layout</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:orientation="vertical" &gt; &lt;com.gui.today.VerticalScrollview android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" tools:context=".MainActivity" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;ProgressBar android:id="@+id/progressBar3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" /&gt; &lt;TextView android:id="@+id/empty_calender" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:text="@string/empty_calender" android:textColor="#ffffff" android:visibility="gone" /&gt; &lt;ListView android:id="@+id/listView2" android:layout_width="fill_parent" android:layout_height="150dp" &gt; &lt;/ListView&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/com.gui.today.VerticalScrollview&gt; </code></pre>
 

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