android - Make whole layout scrollable and not just listview -


i trying make whole layout scrollable in case listview being scrolled , not whole layout. please tell me how can make whole page scrolled , not listview in it. thanks

  1. my xml file

    <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:orientation="vertical" tools:context=".mainactivity">  <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content">  <gridview     android:id="@+id/grid"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:layout_centerinparent="true"     android:columnwidth="100dp"     android:gravity="center"     android:horizontalspacing="2dp"     android:numcolumns="auto_fit"     android:paddingtop="2dp"     android:stretchmode="columnwidth"     android:verticalspacing="2dp" />  </linearlayout>  <textview android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:layout_marginleft="5dp" android:layout_margintop="5dp" android:text="more devices" android:textstyle="bold" />  <listview android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingbottom="3dp" android:paddingleft="3dp" android:paddingtop="3dp" />  </linearlayout> 
  2. my mainactivity.java

package project.example.com.project;

import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.gridview; import android.widget.listview; import android.widget.simpleadapter; import android.widget.toast;  import java.util.arraylist; import java.util.hashmap; import java.util.list;   public class mainactivity extends activity {  gridview grid; string[] gridtext = {"text 1", "text 2", "text 3", "text 4", "text    5", "text 6", "text 7", "text 8", "text 9"}; int[] gridimage = {r.drawable.img, r.drawable.img, r.drawable.img,   r.drawable.img, r.drawable.img, r.drawable.img, r.drawable.img,   r.drawable.img, r.drawable.img}; listview listview; string[] listtext = {"list 1", "list 2", "list 3", "list 4", "list   4", "list 4"}; int[] listimage = {r.drawable.image, r.drawable.image,  r.drawable.image, r.drawable.image, r.drawable.image, r.drawable.image};  @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listview = (listview) findviewbyid(r.id.list); customgrid adapter = new customgrid(mainactivity.this, gridtext,  gridimage); grid = (gridview) findviewbyid(r.id.grid); grid.setadapter(adapter); grid.setonitemclicklistener(new adapterview.onitemclicklistener()    {     @override     public void onitemclick(adapterview<?> parent, view view,                             int position, long id) {         toast.maketext(mainactivity.this, "you clicked @ " +   gridtext[+position], toast.length_short).show();     }     });      list<hashmap<string, string>> list = new  arraylist<hashmap<string, string>>();      string[] = {"txt", "img"};     int[] = {r.id.list_text, r.id.list_image};     simpleadapter simpleadapter = new   simpleadapter(getbasecontext(), list, r.layout.list_row, from, to);     (int = 0; < listtext.length; i++) {     hashmap<string, string> hashmap = new hashmap<string, string> ();     hashmap.put("txt", listtext[i]);     hashmap.put("img", integer.tostring(listimage[i]));     list.add(hashmap);     }      listview.setadapter(simpleadapter);     listview.setonitemclicklistener(new  adapterview.onitemclicklistener() {     @override     public void onitemclick(adapterview<?> parent, view view, int   position, long id) {         toast.maketext(mainactivity.this, "you clicked @ " +            listtext[+position], toast.length_short).show();     }     });     view header = getlayoutinflater().inflate(r.layout.header,  null);     listview.addheaderview(header);       }     } 

in such case have add scrollview :

<scrollview xmlns:android="http://schemas.android.com/apk/res/android"       xmlns:tools="http://schemas.android.com/tools"       android:layout_width="match_parent"       android:layout_height="wrap_content"> . . . </scrollview> 

but remember remove xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools", these 2 lines linearlayout


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -