android - Listview not filling its parent -


i have faced following problem:

i'm trying implement navigation drawer subheadings 1 in gmail app , 1 app:

vk

gmail

as can see, have higlighted there no dividers @ end of each list

so have taken implementation subheadings stack overlfow , have ended this:

myapp know, navigation drawer uses listview , reason why divider there because subheading list item setting option footerdividerenabled false doesn't solve problem.

so next implementaiton put view contatin subheading , listview , added navigation-drawer's listview.

here source code of mainactivity:

package com.myphun.radio;  import java.util.arraylist; import java.util.list;  import android.content.context; import android.os.bundle; import android.support.v7.app.actionbar; import android.support.v7.app.actionbaractivity; import android.view.view; import android.view.viewgroup; import android.widget.abslistview; import android.widget.arrayadapter; import android.widget.linearlayout; import android.widget.listview;  import com.example.androidradio.r; import com.myphun.ui.adapters.listviewadapter; import com.myphun.ui.components.slidingmenulayout;  public class mainactivity extends actionbaractivity {     private slidingmenulayout mslidingmenulayout;     private listview leftdrawerlist;     private listviewadapter madapter;      @override     public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          mslidingmenulayout = (slidingmenulayout) findviewbyid(r.id.main_sliding_menu);         leftdrawerlist = (listview) findviewbyid(r.id.left_drawer_list);          viewarrayadapter viewarrayadapter = new viewarrayadapter(this);         view generic_drawer_view = view.inflate(this, r.layout.sliding_menu_general_section_layout, null);         viewarrayadapter.add(generic_drawer_view);          listview genericcategorieslistview = (listview) generic_drawer_view.findviewbyid(r.id.general_drawer_list);          madapter = new listviewadapter(this);          madapter.additem("mercury", r.drawable.mercury);         madapter.additem("venus", r.drawable.venus);         madapter.additem("earth", r.drawable.earth);         madapter.additem("mars", r.drawable.mars);          madapter.additem("neptune", r.drawable.neptune);         madapter.additem("saturn", r.drawable.saturn);         madapter.additem("uranus", r.drawable.uranus);         madapter.additem("jupiter", r.drawable.jupiter);          genericcategorieslistview.setadapter(madapter);          leftdrawerlist.setadapter(viewarrayadapter);     }  }  class viewarrayadapter extends arrayadapter<view> {      public viewarrayadapter(context context)     {         super(context, 0, new arraylist<view>());     }      public viewarrayadapter(context context, list<view> viewslist)     {         super(context, 0, viewslist);     }      @override     public view getview(int position, view convertview, viewgroup parent)     {         return getitem(position);     } } 

main activity xml:

 <com.myphun.ui.components.slidingmenulayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/main_sliding_menu"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <!-- main content view -->      <framelayout         android:id="@+id/content_frame"         android:layout_width="match_parent"         android:layout_height="match_parent" >          <textview             android:id="@+id/textview122"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="large text"             android:textappearance="?android:attr/textappearancelarge" />     </framelayout>     <!-- navigation drawer -->      <listview         android:id="@+id/left_drawer_list"         android:layout_width="275dp"         android:layout_height="match_parent"         android:layout_gravity="start"         android:background="#444444"         android:choicemode="singlechoice"         android:divider="#555555"         android:dividerheight="0dp"         android:footerdividersenabled="false"         android:headerdividersenabled="false" />  </com.myphun.ui.components.slidingmenulayout> 

custom view:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/general_drawer_view"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >      <textview         android:id="@+id/general_drawer_header"         android:layout_width="match_parent"         android:layout_height="62dp"         android:background="@drawable/list_selector"         android:gravity="bottom"         android:paddingbottom="5dp"         android:paddingright="16dp"         android:text="planets"         android:textcolor="#ffffff"         android:textsize="25sp" />      <view         android:layout_width="fill_parent"         android:layout_height="1dp"         android:background="#ffffff" />      <listview         android:id="@+id/general_drawer_list"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="#ee444444"         android:choicemode="singlechoice"         android:divider="#555555"         android:dividerheight="1dp"         android:footerdividersenabled="false"         android:headerdividersenabled="false" />  </linearlayout> 

but reason, listview doesn't fill entire screen: bad result

i've tried many combination of xml_atributes (i.e. match_parent, wrap_content, fill_parent) , 1 works when set listview layout_height manually (i.e. layout_height ="625dp").

so question is: i'am doing wrong ? how can achieve desire result ? why listview not expanding ?

first of think committing overkill adding listview listview. pretty defats purpose of using listview reusable views in first place , makes layout pretty complexed have provide many adapters , many xml-layout files.

let's 1 thing straight - navigationdrawer can contain view not listview.

if data not fit in one-listview concept maybe should not use @ ? stick linearlayouts. if have dynamic data add addview method sub-linearlayout (sections). if have static navigation declare directly in layout xml file - gain opportunity preview layout without compiling whole project.

if want put lot of items navigationdrawer maybe should rethink whole concept of app? navigation become content hence should not in navigationdrawer.

hope helps, regs.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -