0
package com.example.example2;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
public class MainActivity extends Activity {
    WebView web1;
    WebView web2;
    Button btn;
      @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final String str1 = "<html>This first Html data</html>";
        final 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'  />";
        web1 = (WebView) findViewById(R.id.webfirst);
        web2 = (WebView) findViewById(R.id.websecond);
        btn = (Button) findViewById(R.id.compare);
        btn.setOnClickListener(new OnClickListener() {
       @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                web1.loadDataWithBaseURL("", str1, "text/html", "UTF-8", "");
                web2.loadDataWithBaseURL("", str2, "text/html", "UTF-8", "");

                // we have display This on Alert view with spliting .

            }

        });

    }

}

这是我的拆分视图活动,当我单击按钮时,我们能够通过拆分活动在 Web 视图中查看数据但是当我单击按钮时,我必须这样做,然后字符串 1 和字符串 2 应该显示在同一活动中的弹出窗口中并拆分数据如何在android中拆分警报或弹出视图请帮助我无法做到这一点我已经很累但不知道我会怎么做

4

1 回答 1

0

让您的活动在清单中进行对话是一种方法

<activity android:theme="@android:style/Theme.Dialog" />

通过在您的活动中添加上述代码,您可以将活动视为对话框

(或者)

尝试以这种方式显示自定义对话框

Dialog dialog_help = new Dialog(getActivity());
dialog_help.setContentView(R.layout.help_screen);
TextView tv_1 = (TextView) dialog_help.findViewById(R.id.tv_help_1);
tv_1.setText("");
dialog_help.setCancelable(true);
dialog_help.setTitle("   Help   ");
dialog_help.setCanceledOnTouchOutside(true);
dialog_help.show();
dialog_help.getWindow().setGravity(Gravity.CENTER);
dialog_help.getWindow().setLayout(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
于 2013-09-02T07:32:10.160 回答