google.comのようなウェブサイトにリンクするボタンを作りたいです。jquery mobile + eclipseを使用して、このGoogleで試してみましたが、Android仮想デバイスでは正常に機能しますが、アプリ(apkファイル)を携帯電話に転送すると、そのようには機能しません。思ったようにボタンのないリンクが表示されます。どうしてこんなことに?java、xml、またはandroidfest.xmlファイルにどのコードを追加する必要がありますか?助けてください!!
さらに、ケーブルを使用する代わりに、Bluetoothを介して最終的なapkファイルを転送しました。それが問題になるのでしょうか?:/
私のMainActivity.javaコード:
package com.example.testing;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("file:///android_asset/index.html");
return;
}
}
私のactivity_main.xml:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" />
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
注:実際の電話で想定されていたように、見出しとフッターも表示されませんでした。ヘッダー、フッター、ボタンの機能についてもサポートが必要です。
htmlファイル:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/event.css" />
</head>
<body>
<div data-role="page" data-theme="c" id="home">
<div data-role="header">
<h1>Hello</h1>
</div>
<div data-role="content">
<p>
<a href="https://www.google.com.sg/" rel="external" data-role="button">Google</a>
<a href="http://www.channelnewsasia.com/" rel="external" data-role="button">CNA</a>
</p>
</div>
<div data-role="footer">
<h4>Bye</h4>
</div>
</div>
</body>
</html>