• 3.19 全屏幕以按钮重写


    3.19 全屏幕以按钮重写

    动态产生按钮并最大化  

    问题1:

    问题2:Unable to add window -- token null is not for an application错误的解决方法

    (更多请参考:http://blog.csdn.net/vipa1888/article/details/7034339)

    package edu.cquptzx.FullScreenButton;

     

    import android.app.Activity;

    import android.app.ProgressDialog;

    import android.os.Bundle;

    import android.view.View;

    import android.widget.Button;

     

    publicclass FullScreenButtonActivity extends Activity

    {

        /** Called when the activity is first created. */

        public ProgressDialog pd = null;

        @Override

        publicvoid onCreate(Bundle savedInstanceState)

        {

            super.onCreate(savedInstanceState); 

           

            /* Here we didn't use the main.xlm layout.Instead,we use a button as a layout add to the Activity.*/

            /*这里我们不使用main.xml的布局,而是将按钮作为布局添加到活动中去.*/

            //setContentView(R.layout.main);

           

            Button btn =  new Button(this);

            this.setContentView(btn);

            btn.setText(R.string.btn_text);

            btn.setOnClickListener(

            new  Button.OnClickListener()

                {

                    @Override

                    publicvoid onClick(View v)

                    {

                        CharSequence strDialogTitle = getString(R.string.strDialogTitle);

                        CharSequence strDialogBody = getString(R.string.strDialogBody);

                       

                    /* 下面的方法的第一参数为context,

                     * 此处的context 要保证你的上下文要为activity对象,

                     * 只有activity才能添加ProgressDialog窗体,

                     * 为了确保正确,context可以使用activity.this表示,

                     * 不要一味地写成getApplicationContext()*/

                    /* 下面的种写法只有第一种正确.*/

                    pd = ProgressDialog.show(FullScreenButtonActivity.this, strDialogTitle , strDialogBody,true);

     

                    // pd = ProgressDialog.show(getApplicationContext(), strDialogTitle , strDialogBody,true);

                       

                    //pd = ProgressDialog.show(getBaseContext(), strDialogTitle , strDialogBody,true);

                        new Thread()

                        {

                           publicvoid run()

                           {

                               try

                               {

                                  sleep(3000);

                               }

                               catch( Exception e)

                               {

                                  e.printStackTrace();

                               }

                               finally

                               {

                                  pd.dismiss();

                               }                

                           }

                        }.start();

                    }

                }

                );

           }

    }

     

     

     

     

     

  • 相关阅读:
    GmSSL 与 OpenSSL 共存的安装方法
    爬虫之ssh证书警告错误
    逆向so文件调试工具IDA基础知识点
    frida- registernatives获取so层动态注册函数
    绑定方法与非绑定方法, 反射
    Elk stack安装部署
    类的继承和组合
    安装部署kafka和zookeeper集群(三节点)
    ELK stack 生产问题
    Elasticsearch删除数据操作,你必须知道的一些坑
  • 原文地址:https://www.cnblogs.com/xilifeng/p/2635609.html
Copyright © 2020-2023  润新知