Java 如何在android的Web视图中加载缅甸语?
我有一个web视图,我将在其中输入URL并将该内容加载到该web视图 activity_main.xmlJava 如何在android的Web视图中加载缅甸语?,java,android,android-layout,webview,android-webview,Java,Android,Android Layout,Webview,Android Webview,我有一个web视图,我将在其中输入URL并将该内容加载到该web视图 activity_main.xml <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="m
<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" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:visibility="gone" />
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/urlField"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:ems="10"
android:inputType="textUri"
android:imeOptions="actionDone"
android:hint="http://proteam.in" />
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/layout"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:onClick="open"
android:text="@string/browse" />
</LinearLayout>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_below="@+id/layout" />
</RelativeLayout>
URL 1:
网址2:
我在一些android设备上进行了测试,如moto e(4.4.2)、Dell Vincement 7(4.4.2)、三星Duos GT-s7392(4.1.2)和Videocon z40pro(4.2.2)。上述带有缅甸字体的URL工作正常。但当我尝试在三星GT-s7582(4.2.2)中加载时,web视图中缺少缅甸字体。所以,请告诉我如何解决这个问题。如果您从资源文件夹(我指的是资产文件夹)获取数据,请尝试这种方法。
Java代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonPlayVideo = (Button)findViewById(R.id.playvideoplayer);
Button buttonPlayVideo1 = (Button)findViewById(R.id.button1);
Button acceess = (Button)findViewById(R.id.button2);
getWindow().setFormat(PixelFormat.UNKNOWN);
//Displays a video file.
buttonPlayVideo1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// VideoView refference see main.xml
VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
//String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k;
String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.demo;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
}
});
buttonPlayVideo.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.8/aeon/")); // For Video Content
// new Intent(Intent.ACTION_VIEW, Uri.parse("ftp://movies:movies@192.168.0.8/Transport_Streams/"));
startActivity(browserIntent);
}});
acceess.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(AndroidVideoPlayer.this,Videopage.class);
startActivity(i);
}
});
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF8800"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Welcome To Aeon Group"
android:textColor="#9933CC"
android:textSize="3mm" />
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="394dp"
android:layout_above="@+id/playvideoplayer"
android:layout_alignParentLeft="true" />
<Button
android:id="@+id/playvideoplayer"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="22dp"
android:background="@drawable/button"
android:text="Aeon Content" />
<!-- <VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/playvideoplayer"
android:layout_below="@+id/textView1" />
-->
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_alignParentLeft="true"
android:background="@drawable/button"
android:text="Play" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_toRightOf="@+id/playvideoplayer"
android:background="@drawable/button"
android:text="Acces" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
如果您从URL、FTP服务器或HTTP连接获取数据,请尝试这种方法
Java页面
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonPlayVideo = (Button)findViewById(R.id.playvideoplayer);
Button buttonPlayVideo1 = (Button)findViewById(R.id.button1);
Button acceess = (Button)findViewById(R.id.button2);
getWindow().setFormat(PixelFormat.UNKNOWN);
//Displays a video file.
buttonPlayVideo1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// VideoView refference see main.xml
VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
//String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k;
String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.demo;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
}
});
buttonPlayVideo.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.8/aeon/")); // For Video Content
// new Intent(Intent.ACTION_VIEW, Uri.parse("ftp://movies:movies@192.168.0.8/Transport_Streams/"));
startActivity(browserIntent);
}});
acceess.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(AndroidVideoPlayer.this,Videopage.class);
startActivity(i);
}
});
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF8800"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Welcome To Aeon Group"
android:textColor="#9933CC"
android:textSize="3mm" />
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="394dp"
android:layout_above="@+id/playvideoplayer"
android:layout_alignParentLeft="true" />
<Button
android:id="@+id/playvideoplayer"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="22dp"
android:background="@drawable/button"
android:text="Aeon Content" />
<!-- <VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/playvideoplayer"
android:layout_below="@+id/textView1" />
-->
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_alignParentLeft="true"
android:background="@drawable/button"
android:text="Play" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_toRightOf="@+id/playvideoplayer"
android:background="@drawable/button"
android:text="Acces" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
下面给出了两种方法的XML代码
何时从资源中提取的XML页面
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonPlayVideo = (Button)findViewById(R.id.playvideoplayer);
Button buttonPlayVideo1 = (Button)findViewById(R.id.button1);
Button acceess = (Button)findViewById(R.id.button2);
getWindow().setFormat(PixelFormat.UNKNOWN);
//Displays a video file.
buttonPlayVideo1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// VideoView refference see main.xml
VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
//String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k;
String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.demo;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
}
});
buttonPlayVideo.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.8/aeon/")); // For Video Content
// new Intent(Intent.ACTION_VIEW, Uri.parse("ftp://movies:movies@192.168.0.8/Transport_Streams/"));
startActivity(browserIntent);
}});
acceess.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(AndroidVideoPlayer.this,Videopage.class);
startActivity(i);
}
});
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF8800"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Welcome To Aeon Group"
android:textColor="#9933CC"
android:textSize="3mm" />
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="394dp"
android:layout_above="@+id/playvideoplayer"
android:layout_alignParentLeft="true" />
<Button
android:id="@+id/playvideoplayer"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="22dp"
android:background="@drawable/button"
android:text="Aeon Content" />
<!-- <VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/playvideoplayer"
android:layout_below="@+id/textView1" />
-->
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_alignParentLeft="true"
android:background="@drawable/button"
android:text="Play" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/playvideoplayer"
android:layout_alignBottom="@+id/playvideoplayer"
android:layout_toRightOf="@+id/playvideoplayer"
android:background="@drawable/button"
android:text="Acces" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Dilip:谢谢你的回复。我需要一个应用程序,它应该像我上面提到的那样从URL获取数据(URL 1:URL 2:)。它应该是动态的,请求是在应用程序本身处理的,而不是像(Chrome)这样的任何外部应用程序。是的,我有你的问题,所以你可以使用第二个代码intent@user2969177你想在android mobile中显示整个页面,该URL的和正确吗????@Dhilip Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));startActivity(browserint),但这段代码询问在chrome或Firefox中打开的位置。我喜欢在我的web视图中显示该页面本身。@user2969177**当你解析任何url时,它会使用automtic浏览器**