Wednesday, April 17, 2013

[android help] I'm unable to call a Fragment within onTabSelected of another Fragment that implements ActionTab Listener


I am trying to create a Fragment that has a ListView in the content section, as a default view. There are ActionBar tabs to this view. I'm able to create that so far.


The LaunchListFragment Code



public class LaunchListFragment extends ListFragment implements ActionBar.TabListener {
public static String LIST_TYPE = "invalid";
GenericListData g_data[] = null;
private ViewPager mViewPager;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View result = inflater.inflate(R.layout.fragment_launch_list,
container, false);

setActionTabs();
setList();
return (result);
}

public static LaunchListFragment newInstance(String type) {
LaunchListFragment frag = new LaunchListFragment();
Bundle args = new Bundle();
LIST_TYPE=type;

args.putString(LIST_TYPE, type);
frag.setArguments(args);

return (frag);
}


What I wanted is, when you click the onTabSelected(), would like to change the views and I am using PagerFragment with views generated using an FragmentPagerAdapter



@Override
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {

getChildFragmentManager().beginTransaction()
.add(android.R.id.content,
new PagerFragment()).commit();
}


The trouble is, I can't use getChildFragmentManager or getFragmentManager to call the PagerFragment, I get compilation errors to change the PagerFragment to app.Fragment. Even if I change that, it still complaints.


I suspect there is some sort of clash between support.Fragment and app.Fragment.


Is there a different way of approach to acheive this other than using nested Fragments?


Any help appreciated.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...