原谅我是小白 ,我怎么都感觉看不懂了
在这个VpSimpleFragment类中那个获取VpSimpleFragment对象的方法为什么要这么设计啊?这就是单例模式吗?感觉好像很厉害的样子。。。求解惑啊,为什么要这么弄啊?
在这个VpSimpleFragment类中那个获取VpSimpleFragment对象的方法为什么要这么设计啊?这就是单例模式吗?感觉好像很厉害的样子。。。求解惑啊,为什么要这么弄啊?
2016-03-09
private String mTitle ;
private final static String BUNDLE_TITLE = "title" ;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle bundle = getArguments() ;
if(bundle!=null){
mTitle = bundle.getString(BUNDLE_TITLE) ;
}
TextView text = new TextView(this.getActivity()) ;
text.setText(mTitle);
text.setGravity(Gravity.CENTER);
return text;
}
public static VpSimpleFragment newInstance(String title){
Bundle bund = new Bundle();
bund.putString(BUNDLE_TITLE, title);
VpSimpleFragment fragment = new VpSimpleFragment() ;
fragment.setArguments(bund);
return fragment ;
}附上代码
举报