我在Android開發方面的新的,所以要求你的幫助。添加的AdBlock到佈局的Android
我有這樣的代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/home_layout"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_above="@+id/adView">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:id="@+id/progressBar" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
以我的邏輯,廣告攔截應的視圖底部顯示。但在我的情況下,它根本沒有出現。如果我在LinearLayout
之內通過Ad的標記,它會讓我崩潰。
我在做什麼錯了?謝謝你在前進
UPD:Java的活動
public class PddViewActivity extends ActionBarActivity{
private WebView webView;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pdd_view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
String file = getIntent().getStringExtra("file");
webView = (WebView) findViewById(R.id.webview);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
Log.i("PROGRESS IS :", newProgress+"");
progressBar.setProgress(newProgress);
}
});
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(getApplicationContext(), "Error: " + description + " " + failingUrl, Toast.LENGTH_LONG).show();
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
if (progressBar.getVisibility() == WebView.VISIBLE) {
progressBar.setVisibility(WebView.GONE);
}
}
});
webView.loadUrl(String.format("file:///android_asset/html/%s", file));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
}
你有任何錯誤,當您嘗試編譯?與您的活動相對應的Java代碼是什麼? –
谷歌的指示是什麼? –
重試,並按照這些指令:[AdMob的快速啓動(https://developers.google.com/admob/android/quick-start) –