标签:getview new viewgroup pac imp ati and super ide
package com.bpj.lazyfragment;
import android.support.v4.app.Fragment;
/*
*baseFragment
*/
public class LazyFragment extends Fragment {
/**
* 当前Fragment是否显示:true,显示
*/
public boolean isVisible ;
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
isVisible = false;
if(getUserVisibleHint()){
isVisible = true;
onVisible();
}
}
protected void onVisible(){
}
}
/*
*子Fragent
*/
package com.bpj.lazyfragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends LazyFragment {
public static Fragment2 newInstance(){
Fragment2 fragment1 = new Fragment2();
return fragment1;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment2,null);
return view;
}
@Override
public void setMenuVisibility(boolean menuVisible) {
super.setMenuVisibility(menuVisible);
if (this.getView() != null)
this.getView()
.setVisibility(menuVisible ? View.VISIBLE : View.GONE);
}
@Override
protected void onVisible() {
//刷新的方法
System.out.println("Fragment2开始加载。。。");
}
}
标签:getview new viewgroup pac imp ati and super ide
原文地址:http://www.cnblogs.com/huihuizhang/p/6056344.html