如何获取分配给片段的每个页面中每个字符串的状态?

时间:2016-11-04 12:12:01

标签: android android-viewpager fragmentpageradapter

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    //Animation animation = AnimationUtils.loadAnimation(this.getContext(), R.anim.fade);

    sectionlabeltextview = (TextView) rootView.findViewById(R.id.section_label);
    sectionlabeltextview.setText(getArguments().getString("text"));
    sectionlabeltextview.setTextColor(Color.BLACK);
    sectionlabeltextview.setTextSize(25);
    sectionlabel_text = (String) sectionlabeltextview.getText();
    Toast.makeText(getContext(),sectionlabel_text,Toast.LENGTH_SHORT).show();
    Log.e("sectionlabel_text",sectionlabel_text);
    SharedPreferences sharedPref=getActivity().getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor=sharedPref.edit();
    editor.putString("catch_text",sectionlabel_text);
    editor.commit();

    //sectionlabeltextview.startAnimation(animation);
    //sectionlabeltextview.setGravity();

    return rootView;
}

这里sectionlabel_text和toast消息的值有所不同,虽然两者都在同一个函数中。请尝试给出解决方案吗?

0 个答案:

没有答案