android - How to put swipe tab views inside one of navigation drawer option -
updated code:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_home, container, false); viewpager = (viewpager)view.findviewbyid(r.id.base_pager); fragmentmanager manager = getchildfragmentmanager(); viewpager.setadapter(new myfragmentpageradapter(manager)); return rootview; } class homefragment extends fragmentpageradapter { public homefragment(fragmentmanager fm) { super(fm); // todo auto-generated constructor stub } @override public android.support.v4.app.fragment getitem(int item) { // todo auto-generated method stub android.support.v4.app.fragment fragment = null; if (item == 0) { //mapfragment.message("map"); fragment = new mapfragment(); } else if (item == 1) { //savedlocationsfragment.message("locations"); fragment = new mapfragment(); } /*else if (item == 2) { fragment = new fragmentc(); }*/ return fragment; } @override public int getcount() { // todo auto-generated method stub return 2; } @override public charsequence getpagetitle(int position) { // todo auto-generated method stub string title = new string(); if (position == 0) { title = "map"; } else if (position == 1) { title = "savedlocations"; } return title; } }
i getting error on oncreateview method;
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_home, container, false); viewpager = (viewpager)view.findviewbyid(r.id.base_pager); fragmentmanager manager = getchildfragmentmanager(); viewpager.setadapter(new myfragmentpageradapter(manager)); return rootview; }
the error are;
- the annotation @override disallowed location
- syntax error on token "view", @ expected
- syntax error on token "layoutinflater", = expected after token
- syntax error on token "viewgroup", = expected after token
- syntax error on token "bundle", = expected after token
in home fragment this
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // todo auto-generated method stub view view = inflater.inflate(r.layout.fragment_activity, container, false); viewpager = (viewpager)view.findviewbyid(r.id.base_pager); fragmentmanager manager = getchildfragmentmanager(); viewpager.setadapter(new myfragmentpageradapter(manager)); return view; } class myfragmentpageradapter extends fragmentpageradapter { public myfragmentpageradapter(fragmentmanager fm) { super(fm); // todo auto-generated constructor stub } @override public android.support.v4.app.fragment getitem(int item) { // todo auto-generated method stub android.support.v4.app.fragment fragment = null; if (item == 0) { fragment = new photocommnfragment(); } else if (item == 1) { fragment = new showrestaurant(); } /*else if (item == 2) { fragment = new fragmentc(); }*/ return fragment; } @override public int getcount() { // todo auto-generated method stub return 2; } @override public charsequence getpagetitle(int position) { // todo auto-generated method stub string title = new string(); if (position == 0) { title = "map"; } else if (position == 1) { title = "restaurant"; } else if (position == 2) { title = "table 2"; } return title; } }
now able call child fragment of home, this
your mainactivity mother home fragment child of mainactivity. , in home fragment hosting reasturant , map fragment. kindly check how dex2jar, if can't mail relevant code
Comments
Post a Comment