zoukankan      html  css  js  c++  java
  • Android开发笔记

    1.使用AlertDialog.Builder 对话框自定义view,并通过setview设置

     AlertDialog.Builder dlgAlert;
                dlgAlert = new AlertDialog.Builder(this);
                LayoutInflater inflater = getLayoutInflater();
    
                dlgAlert.setTitle("用户协议");
                //dlgAlert.setMessage(R.string.agreement);
                View checkView=inflater.inflate(R.layout.agreedialogview,null);
                dlgAlert.setView(checkView);
                CheckBox agreeCheck=(CheckBox)checkView.findViewById(R.id.checkBox_agree);;
                dlgAlert.setPositiveButton("确定",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                // if this button is clicked, close current activity
                                if (agreeCheck.isChecked()) {
                                    init();
                                }
                                else
                                {
                                    finish();
                                    System.exit(0);
                                }
                            }
                        }).create();
    
                dlgAlert.setNeutralButton("退出",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                // if this button is clicked, close current activity
                                finish();
                                System.exit(0);
                            }
                        }).create();
                dlgAlert.show();

    这里要想在对话框按钮的监听事件中调用xml布局里面的控件,不能直接findViewById,需要这样写

    View checkView=inflater.inflate(R.layout.agreedialogview,null);
                dlgAlert.setView(checkView);
                CheckBox agreeCheck=(CheckBox)checkView.findViewById(R.id.checkBox_agree);;

    对话框.show()函数之后才可以调用,

    2.wab页面打不开和无法下载问题

    提示:

    位于..... 的网页无法加载,因为:net::ERR_CLEARTEXT_NOT_PERMITTED

    原因是从Android 6.0开始引入了对Https的推荐支持,与以往不同,Android P的系统上面默认所有Http的请求都被阻止了。

    解决方法如下:

    在清单文件里加入android:usesCleartextTraffic="true"这句

    <?xml version="1.0" encoding="utf-8"?>
    <manifest ...> 
        <uses-permission android:name="android.permission.INTERNET" />
     
        <application
            ...
            <!-- 加入下面这句 -->
            android:usesCleartextTraffic="true"
            ...>
            ...
        </application>
    </manifest>

    未完待续

  • 相关阅读:
    P1017 进制转换
    P1100 高低位交换
    P1469 找筷子
    P1866 编号
    SQL常用语句(T-SQL、PL/SQL)
    Proxyer内网穿透配置教程
    使用JS检测自定义协议是否存在
    C# 代码启动ClickOnce应用
    SQL Server 异地备份到远程共享文件夹异常处理
    发布ClickOnce应用程序步骤与URL传参应用
  • 原文地址:https://www.cnblogs.com/pozhu15/p/11419725.html
Copyright © 2011-2022 走看看