android - Is it possible to disable scroll on a listView? -


i dynamically add items listview , want make items visible, without scrolling.

layout code:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/recipe_inside" android:orientation="vertical" >  <scrollview     android:layout_width="match_parent"     android:layout_height="wrap_content" >      <linearlayout         xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="vertical" >          <imageview             android:id="@+id/imageview1"             android:layout_width="match_parent"             android:layout_height="16dp"             android:src="@drawable/head_cella" />          <textview             android:id="@+id/textview1"             android:layout_width="wrap_content"             android:layout_height="41dp"             android:background="@drawable/body_cella"             android:gravity="center_horizontal"             android:paddingtop="5dp"             android:text="remember save before leaving page or inserted/modified data lost."             android:textcolor="#000000"             android:textsize="13dp" />          <imageview             android:id="@+id/imageview01"             android:layout_width="match_parent"             android:layout_height="16dp"             android:layout_margintop="30dp"             android:src="@drawable/head_cella" />          <textview             android:id="@+id/textview01"             android:layout_width="wrap_content"             android:layout_height="35dp"             android:background="@drawable/body_cella"             android:gravity="center_horizontal"             android:paddingtop="10dp"             android:text="category"             android:textcolor="#000000"             android:textsize="15dp" />          <spinner             android:id="@+id/category_spinner"             android:layout_width="match_parent"             android:layout_height="wrap_content" />          <imageview             android:id="@+id/imageview02"             android:layout_width="match_parent"             android:layout_height="16dp"             android:layout_margintop="30dp"             android:src="@drawable/head_cella" />          <textview             android:id="@+id/textview02"             android:layout_width="wrap_content"             android:layout_height="35dp"             android:background="@drawable/body_cella"             android:gravity="center_horizontal"             android:paddingtop="10dp"             android:text="name"             android:textcolor="#000000"             android:textsize="15dp" />          <edittext             android:id="@+id/recipe_title"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:ems="10"             android:hint="recipe title" android:lines="1"/>          <imageview             android:id="@+id/imageview03"             android:layout_width="match_parent"             android:layout_height="16dp"             android:layout_margintop="30dp"             android:src="@drawable/head_cella" />          <textview             android:id="@+id/textview03"             android:layout_width="wrap_content"             android:layout_height="35dp"             android:background="@drawable/body_cella"             android:gravity="center_horizontal"             android:paddingtop="10dp"             android:text="ingredients"             android:textcolor="#000000"             android:textsize="15dp" />          <listview             android:id="@android:id/list"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:layout_weight="1" android:cachecolorhint="#00000000" android:divider="#00000000"             android:isscrollcontainer="false"             >        </listview>           <button              android:id="@+id/button_ing"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:text="" android:background="@drawable/add_recipe_button" android:onclick="additems"/>      </linearlayout>  </scrollview></linearlayout> 

old oncreate() function code:

protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);      setcontentview(r.layout.add_recipe_form);      spinner = (spinner)myhead.findviewbyid(r.id.category_spinner);      cursor cursor = mydb.getcategorieslist();     arraylist<category> list = new arraylist<category>();     list.add(new category(0,"choose category"));      while (cursor.movetonext()) {         list.add(new category(cursor.getint(0),cursor.getstring(1)));      }     // step 2: create , fill arrayadapter bunch of "state" objects     arrayadapter spinnerarrayadapter = new arrayadapter(this,android.r.layout.simple_spinner_item, list);      // step 3: tell spinner our adapter     spinner.setadapter(spinnerarrayadapter);        spinner.setonitemselectedlistener(this);       setlistadapter(adapter);     ingredients.add((view)findviewbyid(r.layout.row_add_recipe));     adapter.notifydatasetchanged(); } 

if move code related fill spinner database data, returns me nullpointerexception it's not found in layout. need keep here , solution adding addheaderview() listview seems ok, have nullpointerexception regarding head layout:

protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);      setcontentview(r.layout.add_recipe_form);     listview mylistview = (listview) findviewbyid(android.r.id.list);     linearlayout myhead = (linearlayout)findviewbyid(r.id.linear_form);     mylistview.addheaderview(myhead);     spinner = (spinner)myhead.findviewbyid(r.id.category_spinner);      cursor cursor = mydb.getcategorieslist();     arraylist<category> list = new arraylist<category>();     list.add(new category(0,"choose category"));      while (cursor.movetonext()) {         list.add(new category(cursor.getint(0),cursor.getstring(1)));      }     // step 2: create , fill arrayadapter bunch of "state" objects     arrayadapter spinnerarrayadapter = new arrayadapter(this,android.r.layout.simple_spinner_item, list);      // step 3: tell spinner our adapter     spinner.setadapter(spinnerarrayadapter);        spinner.setonitemselectedlistener(this);       setlistadapter(adapter);     ingredients.add((view)findviewbyid(r.layout.row_add_recipe));     adapter.notifydatasetchanged(); } 

if understand well, need more views wich scrollable along listview. best way implement call addheaderview() , addfooterview() on listview().

edit:

it should go this, think:

@override public void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.your_main_layout);     layoutinflater inflater = (layoutinflater)getsystemservice(context.layout_inflater_service);     view header = inflater.inflate(r.layout.your_header_layout); //r.layout, not r.id!      (listview) list = findviewbyid(android.r.list);     list.addheaderview(header);      list.setadapter(adapter); //according docs should call setadapter() after addheaderview()      //to spinner     (spinner) spinner = (spinner) header.findviewbyid(r.id.spinner);  } 

i'm writing memory , didn't test it, think should work. try out when moment.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

java - stack overflow exception on xml transformation -