Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
966 views
in Technique[技术] by (71.8m points)

java - How to use shared preference to send data from activity to fragment?

I'm trying to send integer value from activity to a fragment to change text size value, Iv tried user bundle and custom constructor and didn't work. So how can I use shared preferences for this purpose?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Hey have you tried something like this

Bundle bundle=new Bundle();
bundle.put('key',0);
FragmentName name=new FragmentName();
name.setArguements(bundle);
Integer q=getArguments.getInt(key)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...