SquiresSquire
SquiresSquire

Reputation: 2414

Android View pager & List fragment

I have successfully gotten a 3 tab + pager implemented.

One of these tabs is a List fragment, how would I update the fragment with the onclick method, and still be able to keep the tabs??

Upvotes: 2

Views: 838

Answers (1)

kyogs
kyogs

Reputation: 6836

You cannot replace a fragment defined statically in the layout file. You can only replace fragments that you added dynamically via a FragmentTransaction.as here

You can only replace a "dynamically added fragment".

private void addDynamicFragment() {
        // TODO Auto-generated method stub
               // creating instance of the HelloWorldFragment.
        Fragment fg = HelloWorldFragment.newInstance();
        // adding fragment to relative layout by using layout id
        getFragmentManager().beginTransaction().add(R.id.layout, fg).commit();
    }

So, if you want to add a dynamic fragment, see this example check this link

Upvotes: 1

Related Questions