Im trying to pass data between two fragmens in my program. Its just a simple string that is stored in the List. The List is made public in fragments A, and when the user clicks on a list item, I need it to show up in fragment B. The content provider only seems to support ID's, so that will not work. Any suggestions?
Why don't you use a Bundle. From your first fragment, here's how to set it up:
Fragment fragment = new Fragment(); Bundle bundle = new Bundle(); bundle.putInt(key, value); fragment.setArguments(bundle);
Then in your second Fragment, retrieve the data using:
Bundle bundle = this.getArguments(); int myInt = bundle.getInt(key, defaultValue);
Bundle has put methods for lots of data types. Please see http://developer.android.com/reference/android/os/Bundle.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With