2012-03-06 6 views
3

ので、私の最初の質問、アンドロイドショー内部のhtmlファイル

は私のアプリの "res"フォルダにeclipseでドラッグ&ドロップするだけです。

そうであれば、 はどのように私は場所を参照することができます。

のres \ HTML \

index.htmlのように私は私のアプリでのindex.htmlを表示することができますか?

私のUrlを変更するには、URIを操作するには?

mWebView.loadUrl( "http://www.google.com");

このパスは変更する唯一のものですか?

ありがとうございました!

答えて

6

assetsフォルダのindex.htmlファイルを削除します。その後、その中にWebViewlayoutを作成し、Activity

setContentView(R.layout.html_layout); //load the layout XML file 
WebView mbrowser = (WebView) findViewById(R.id.mwebview); //get the WebView from the layout XML 
mbrowser.loadUrl("file:///android_asset/index.html"); //set the HTML 

html_layout.xmlで、このようなレイアウトとして設定します:

<?xml version="1.0" encoding="utf-8"?> 
    <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mwebview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 
関連する問題