Fragment之间传值CallBack(Fragment02)

来源:互联网 发布:多核编程的艺术 编辑:程序博客网 时间:2024/06/08 13:10
package com.bwie.fragmentcallback;import android.content.Context;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView;/** * Created by Shadow on 2017/7/11. */public class Fragment02 extends Fragment {    private View view;    @Override    public void onAttach(Context context) {        super.onAttach(context);    }    @Nullable    @Override    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {        view = inflater.inflate(R.layout.fragment2, container, false);        return view;    }    @Override    public void onActivityCreated(@Nullable Bundle savedInstanceState) {        super.onActivityCreated(savedInstanceState);    }    public void setText(String s){        TextView fragment2_tv = (TextView) view.findViewById(R.id.fragment2_tv);        fragment2_tv.setText(s);    }}
原创粉丝点击