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();

                    }

                }

                );

           }

    }

     

     

     

     

     

  • 相关阅读:
    说明因 Active Directory 冲突导致的 NTDS 复制警告 ID 1083 和 1061 以及 SAM 错误 ID 12294
    KB817701:可用于解决帐户锁定问题的 Service Pack 和修复程序
    log check
    AD account 锁定问题
    VS.2005 中比较有用的快捷键
    用户帐户意外锁定, 以及 Windows Server 2003 中记录事件 ID 12294
    xp 重新安装MDAC
    [学习收藏]业界三种架构优缺点比较
    [收藏学习]Linux内核虚拟机 学习KVM架构及其优点
    两个命令:hdparm和iozone参数解释
  • 原文地址:https://www.cnblogs.com/xilifeng/p/2635609.html
Copyright © 2011-2022 走看看