【发布时间】:2016-03-30 06:27:14
【问题描述】:
我正在为农民开发一个 android 信息应用程序。信息将以当地印度语言提供。我为此目的使用 webview。信息存储在 html 文件中。问题是本地语言的信息不是可见。如何解决?
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Getting reference to WebView of the activity_main layout
mWebView = (WebView) findViewById(R.id.webview);
// Loading an html page into webview
mWebView.loadUrl("file:///android_asset/text.html");
}
活动主要
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res /android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_world" />
</RelativeLayout>
html文件
<html>
<head>
<meta http-equiv="content-type" content="text/html;" charset="UTF-8">
<style>
/** Specify a font named "MyFont",
and specify the URL where it can be found: */
@font-face {
font-family: "MyFont";
src: url('file:///android_asset/b.ttf');
}
h3 { font-family:"MyFont"}
</style>
</head>
<body>
<h3>
ಪ್ರಶಾಂತ
</h3>
</body>
【问题讨论】:
-
像
text-xy.html这样存储您的文件,其中 xy 类似于en、in、... 一个 2 字符短表示语言。然后,根据当前的语言环境,加载相应的文件。
标签: android