最近开发遇到viewpager + fragment 出现滑动几下死机的现象,后来在网上找了一个有用的解决方法
引用解决方案网址:
原fragment写法:
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.lvche.chatuidemo.R;
import com.lvche.origin.activity.XXXActivity;
import com.lvche.origin.utils.Properties;
import com.lvche.origin.webkit.MyWebView;
public class FragmentDemand extends BaseFragment {
public FragmentDemand(MyWebView webview,
XXXActivity XXXActivity) {
super(webview, pggmallFoundingActivity);
}
MyWebView webview = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.pggmall_fragment_demand, container, false);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
webview = (MyWebView) this.getView().findViewById(R.id.baidu);
webview.loadUrl(Properties.WEB_FOUNDING_URL + "?" + "index=2");
FragmentDemand thiz = new FragmentDemand(webview,pggmallFoundingActivity);
/**初始化webview*/
thiz.initWebView();
/**这句话必须放在这个方法最后 ,代表要继承父类的东西最后执行*/
super.onViewCreated(view, savedInstanceState);
}
}