zoukankan      html  css  js  c++  java
  • 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();

                    }

                }

                );

           }

    }

     

     

     

     

     

  • 相关阅读:
    Appium Inspector定位元素与录制简单脚本
    Appium(Python)API
    Appium(Python)驱动手机Chrome浏览器
    Appium(Python)驱动手机淘宝App
    uiautomatorviewer定位App元素
    Android Studio怎样创建App项目
    adb获取设备的序列号
    获取App的PackageName包名和LauncherActivity启动页
    怎样安装Appium
    最小生成树(MST)
  • 原文地址:https://www.cnblogs.com/xilifeng/p/2635609.html
Copyright © 2011-2022 走看看