http://www.cnblogs.com/codeworker/archive/2012/04/23/2467180.html
//判断当前是否有网络连接 private boolean isConn(Context context, LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { if (context != null) { ConnectivityManager conManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = conManager.getActiveNetworkInfo(); if (info == null) { view = inflater.inflate(R.layout.fragment15, container, false); } else { view = inflater.inflate(R.layout.fragment3, container, false); initView(); return info.isAvailable(); } } return false; }