android - Activities and fragments -
here's deal, have simple application in u user log in , view reports. basic architecture of these reports consists of header fragment display user login info, table layout hold report content , footer fragment in have created option menu report providing. now, have different activities each report , start/launch these activites onoptionsitemselected() follows:
getactivity().startactivity(intent);
the first report, menu , items load perfectly. when select menu item menu app stops giving following exception:
04-04 18:29:49.670: e/androidruntime(1123): java.lang.runtimeexception: unable start activity componentinfo{com.example/com.example.report2}: android.view.inflateexception: binary xml file line #10: error inflating class fragment
i guessing happening because next activity contains fragments(header , footer). approach wrong? looking on net, loads of info leaves me confused @ end. appreciated!
*edit : *
layout xml report 1
<?xml version="1.0" encoding="utf-8"?> <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:baselinealigned="false" android:gravity="center" android:orientation="vertical"> <fragment android:name="com.example.headerfragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center" android:layout_weight="1" android:gravity="center_horizontal" tools:layout="@layout/header_fragment" /> <tablelayout android:id="@+id/tblsummrep" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="4" android:padding="5dip"> </tablelayout> <fragment android:name="com.example.footerfragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center" android:layout_weight="1" android:gravity="center_horizontal" tools:layout="@layout/footer_fragment" /> </linearlayout>
the above layout same reports
the code routing menu itmes(in class footer fragment) follows :
@override public boolean onoptionsitemselected(menuitem item) { // handle item selection int switchto = mm.routemenu(item, con); switch (switchto) { case 2: intent = new intent(con, report2.class); isact = "y"; break; case 3: intent = new intent(con, report3.class); isact = "y"; break; case 4: intent = new intent(con, report4.class); isact = "y"; break; case 5: intent = new intent(con, report5.class); isact = "y"; break; case 6: intent = new intent(con, report6.class); isact = "y"; break; default: super.onoptionsitemselected(item); } if(isact.touppercase().equals("y")){ if(login.lstlogin != null){ getactivity().startactivity(intent); } } return true; }
mm.routemenu() in in different class handles things fetching items diplayed database.
also, con activity.getapplicationcontext();
in onattach() event
Comments
Post a Comment