expandablelistview - Java Illegal Argument Exception android -
i having kind of error, after searching possible resources still not work.
error:
java.lang.illegalargumentexception: view android.widget.expandablelistview{416b0bc8 vfed.vc. ......id 0,0-480,0 #7f080005 app:id/lvexp} not drawer
heres code:
expandablelistadapter listadapter; expandablelistview explistview; list<string> listdataheader; private drawerlayout drawer; private linearlayout linear; button btn; hashmap<string, list<string>> listdatachild; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); preparelistdata(); btn = (button)findviewbyid(r.id.button1); linear = (linearlayout)findviewbyid(r.id.linear); explistview = (expandablelistview) findviewbyid(r.id.lvexp); drawer = (drawerlayout)findviewbyid(r.id.drawer_layout); btn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub if(!drawer.isdraweropen(explistview)) { drawer.opendrawer(explistview); } else { drawer.closedrawer(explistview); } } }); // listview // preparing list data listadapter = new expandablelistadapter(this, listdataheader, listdatachild); // setting list adapter explistview.setadapter(listadapter);
for xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#f4f4f4" > <linearlayout android:id="@+id/linear" android:layout_width="match_parent" android:layout_height="50dp" android:background="#000000" android:orientation="vertical" > <linearlayout android:layout_width="wrap_content" android:layout_height="match_parent" > <button android:id="@+id/button1" android:layout_width="47dp" android:layout_height="45dp" android:background="@drawable/ic_home" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="drawer" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> <android.support.v4.widget.drawerlayout android:id="@+id/drawer_layout" 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" /> <!-- navigation drawer --> <expandablelistview android:id="@+id/lvexp" android:layout_width="match_parent" android:layout_height="match_parent" android:cachecolorhint="#00000000" > </expandablelistview> </android.support.v4.widget.drawerlayout> </linearlayout> </linearlayout>
you getting exception on if(!drawer.isdraweropen(explistview))
explistview list not drawer. thats why getting java.lang.illegalargumentexception:
Comments
Post a Comment