这节课
package com.example.foootnotes;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
public class compare extends Activity {
WebView web1;
WebView web2;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.compare);
// String str1="<html>This first Html data</html>";
String str2 = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework"
+ "help help with homework homework assignments elementary school high school middle school"
+ "// --><font color='#60c000' size='4'><strong>Please!</strong></font>"
+ "<img src='http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif' />";
Intent i = getIntent();
String str1 = i.getStringExtra("htmlrespones");
web1 = (WebView) findViewById(R.id.webfirst);
web2 = (WebView) findViewById(R.id.websecond);
web1.loadDataWithBaseURL("", str1, "text/html", "UTF-8", "");
web2.loadDataWithBaseURL("", str2, "text/html", "UTF-8", "");
btn = (Button) findViewById(R.id.compare);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
WebView web5 = (WebView) findViewById(R.id.webView1);
WebView web6 = (WebView) findViewById(R.id.webView2);
web5.loadDataWithBaseURL("", "This is first ", "text/html",
"UTF-8", "");
final Dialog dialog = new Dialog(compare.this);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Differences");
Button dialogButton = (Button) dialog
.findViewById(R.id.dialogButtonOK);
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
}
我的自定义 .xml 文件
<?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" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/image"
android:textColor="#FFF" />
/>
<Button
android:id="@+id/dialogButtonOK"
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_below="@+id/image"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text=" Ok " />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/dialogButtonOK"
android:layout_marginTop="41dp"
android:text="This is for first Html"
android:textStyle="bold" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:text="This is for scond Html" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1" />
<WebView
android:id="@+id/webView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/webView1" />
</RelativeLayout>
我能够显示 Textview 但是我想在自定义对话框中的 Web 视图中显示数据,当我在 Textview 中显示它时它工作正常但是我在 Webview 中显示大数据我无法在 Textview 中显示数据所以请告诉我如何在 webview 中显示数据在Coustome dilog ..请帮助!