简体   繁体   中英

Information from one fragment is not sending to another

I have a main Activity which contains two Fragments (Each in it's own activity) as ActionTabListener

在此处输入图片说明

Everytime I hit the Calculate button I want the information to append on top of what's already under Display Result activity textbox and not overwrite. I tried SharedPreference, but it only works to setText() but .append() doesn't work.

The TextBox is initialized under the Display Trip as

private EditText showLog;

Should I change it to private ?

How do I transfer information between the two activities without losing them within the duration of the application in the memory?

Try this,

 Practice2 newFragment = new Practice2();

                bundle.putString("id", "Information");
                newFragment.setArguments(bundle);

                android.support.v4.app.FragmentManager fragmentManager = getFragmentManager();
                android.support.v4.app.FragmentTransaction transaction = fragmentManager
                        .beginTransaction();

                transaction.replace(R.id.llhome, newFragment);

                // Commit the transaction
                transaction.commit();

and replace the current version of display result with it's self but with the information and if you want you can attach multiple bundles for each string you want to show.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM