Skip to content Skip to sidebar Skip to footer

Passing Parameters Between Activities/fragments

Hello Android developers, I'm trying to pass arguments between two distinct activities but I've got stuck into an issue and I can't get out of it. Basically, I'm trying to pass two

Solution 1:

I will Explain all scenarios

When You pass data From Activity To a fragment You can use setArguments that takes a Bundle contain your data Function on Fragment Instance exactly before committing the Transition

An Example

DetailsFragmentdFragment=newDetailsFragment();
                    Bundlebundle=newBundle();
                    bundle.putParcelable(Intent.EXTRA_TEXT, movies);
                    dFragment.setArguments(bundle);
                    getSupportFragmentManager().beginTransaction().replace(R.id.panel_two_id, dFragment).commit(); 

the Second scenario is

In your fragment you can call getActivity(). This will give you access to the activity that created the fragment. From there you can obviously call any sort of accessor methods that are in the activity.

Solution 2:

Your code should be working from what I see, I noticed you set the onClickListener doing a "new" statement. Are you sure this is the only time you do this on the same TextView?

Post a Comment for "Passing Parameters Between Activities/fragments"