1
我需要的是當用戶打開我的應用程序並且他或她沒有任何互聯網連接時,webview會顯示我在Photoshop中設計的屏幕。所以基本上不是標準的沒有網絡錯誤當應用程序無法連接時顯示「沒有互聯網連接」屏幕
這裏是我的xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:clickable="false"
tools:context=".MyActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:gravity="center"
android:text="@string/vu"
android:textColor="#000000"
android:textSize="60sp" />
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3486775169258180/1572732950" />
</RelativeLayout>
,這裏是java類 -
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
TextView tv = (TextView) findViewById(R.id.textView);
Typeface typeface = Typeface.createFromAsset(getAssets(), "BebasNeue Light.ttf");
tv.setTypeface(typeface);
WebView webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("");
webView.setWebViewClient(new WebViewClient());
webView.setVerticalScrollBarEnabled(false);
webView.setOverScrollMode(View.OVER_SCROLL_NEVER);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
}
在哪裏是你的代碼嗎?你可以請出示嗎? – joao2fast4u 2014-09-20 18:10:28
編輯它,看看 – CristianoWilson 2014-09-20 18:19:15
你在哪裏檢查互聯網連接? – joao2fast4u 2014-09-20 18:21:36