您的位置:首页 > 其它

动态创建fragment

2017-09-18 07:41 183 查看
package wld.bawei.com.huadong;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
* Created by 大金鑫 on 2017/9/11.
*/

public class Fragmentt extends Fragment{
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
String name = arguments.getString("args");
TextView textView = new TextView(getActivity());
textView.setText(name);
return textView;
}
public static Fragment getInstance(String title) {
Fragmentt fragment0 = new Fragmentt();
Bundle args = new Bundle();
args.putString("args", title);
fragment0.setArguments(args);
return fragment0;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: