2011-01-26 9 views
0

webviewtable rowに追加していますが、データがロードされていますが、データが表示されません。 linear layoutが動作していますが、テーブル行のあるtable layoutで動作していない場合は、WebViewのテーブルレイアウト

* main.xml *

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
     > 
    <TableLayout 
     android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <TableRow android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <WebView android:id="@+id/link4_view" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"/> 
     </TableRow> 

    </TableLayout> 

</LinearLayout> 

SampleWebCheckActivity.java

package com.samplecheck; 
import android.app.Activity; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.text.util.Linkify; 
import android.view.View; 
import android.webkit.WebView; 
import android.widget.Button; 
import android.widget.TextView; 

public class SampleWebCheckActivity extends Activity 
{ 

    /** Called when the activity is first created. */ 

    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     WebView wv=(WebView)findViewById(R.id.link4_view); 
     String data="sample 1234 2345 5678 123456 "; 
     wv.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null); 

     // wv.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, failUrl)(data, "text/html", "UTf-8"); 

    } 
} 

でも、私はそれが働いていないloaddataのを使用しました。

答えて

1

loadDataWithBaseURLの最初のパラメータにnullを指定しています(デフォルトは about:blank)。

これを試してみてください:

WebView on Android Developerは実際には非常に素晴らしい説明があります。

2

私はこのようなmain.xmlを持っている...

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <TableRow > 
     <android.webkit.WebView 
      android:id="@+id/webView1" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 

そして、このようなコード...

WebView webView = (WebView) findViewById(R.id.webView1); 
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); 
    webView.loadUrl("file:///android_asset/flashcard.html"); 

このようなHTMLファイル...

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>temp</title> 
</head> 
<body style="background-color: black; color: white;"> 
    <p> 
    <strong>Hello</strong> World! 
    </p> 
    <p>This is too cool</p> 
</body> 
</html> 

元のポスターの説明とまったく同じです。一貫して動作するには、WebViewをTableLayout/TableRowの組み合わせの中に置かないでください。さらに、HTMLファイル内のスペースや何かに応じて、動作していて動作していませんでした。

私にとって、これは非常にバグのようです。 Androidの開発は一般的に非常に面倒でバグが多いです。あなたは物事をちょうど良いものにしなければならない、あるいは単に働かないだけです。私は全体的にアンドロイドが大好きですが、開発はうんざりです。

+0

それはバグかレイアウトのマークアップの制限であるかどうかはまだわかりませんが、表の行は、その要素に含まれる要素の高さを取得します。起動時にWebviewの高さは0であるため、必要な情報がWebビューに読み込まれても表示されなくても – mckjerral

関連する問題