android 程序设置全屏显示

2中方法

 

在AndroidManifest.xml中

<activity android:name=””

android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”/>

 

程序里

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

android使用ZipInputStream解压缩zip压缩文件

public class unzip extends Activity {
  /** Called when the activity is first created. */
  static final int BUFFER = 2048;
  TextView textView;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    textView = new TextView(this);
    super.onCreate(savedInstanceState);
    textView.setText(“Main Activity”);
    extractZipfile();
    setContentView(textView);
  }
  private void extractZipfile() {
    String extractDir = getApplicationContext().getFilesDir()
            .getAbsolutePath()
            + “/unzip/”;
    try {
      BufferedOutputStream dest = null;
      ZipInputStream zis = new ZipInputStream(getResources()
              .openRawResource(R.raw.book));
      ZipEntry entry;
      while ((entry = zis.getNextEntry()) != null) {
        File file = new File(extractDir + entry.getName());
        if (file.exists()) {
          textView.append(“n” + file.getAbsolutePath() + “texists”);
          continue;
        }
        if (entry.isDirectory()) {
          if (!file.exists())
            file.mkdirs();
          textView.append(“nCreate directory: “
                  + file.getAbsolutePath());
          continue;
        }
        textView.append(“nExtracting:” + entry);
        int count;
        byte data[] = new byte[BUFFER];
        textView.append(” to ” + file.getAbsolutePath());
        FileOutputStream fos = new FileOutputStream(file);
        dest = new BufferedOutputStream(fos, BUFFER);
        while ((count = zis.read(data, 0, BUFFER)) != -1) {
          dest.write(data, 0, count);
        }
        dest.flush();
        dest.close();
      }
      zis.close();
    } catch (Exception e) {
        // TODO: handle exception
      e.printStackTrace();
    }
  }
}

android sdk下载地址

ADT 10.0.0下载地址

http://dl.google.com/android/ADT-10.0.0.zip

 

下载下列文件时加前缀 
https://dl-ssl.google.com/android/repository/

API 2
android-1.1_r1-windows.zip
android-1.1_r1-macosx.zip
android-1.1_r1-linux.zip

API 3
android-1.5_r03-windows.zip
android-1.5_r03-linux_x86.zip
android-1.5_r03-mac_x86.zip
google_apis-3-r03.zip 

API 4
android-1.6_r02-windows.zip
android-1.6_r02-linux.zip
android-1.6_r02-macosx.zip
google_apis-4_r02.zip

API 5
android-2.0_r01-windows.zip
android-2.0_r01-linux.zip
android-2.0_r01-macosx.zip
google_apis-5_r01.zip

API 6
android-2.0.1_r01-linux.zip
android-2.0.1_r01-macosx.zip
android-2.0.1_r01-windows.zip
google_apis-6_r01.zip

API 7
android-2.1_r01-windows.zip
samples-2.1_r01-linux.zip
android-2.1_r01-macosx.zip
google_apis-7_r01.zip

 

API 8

android-2.2_r02-windows.zip

android-2.2_r02-macosx.zip

tools
tools_r05-windows.zip
tools_r05-linux.zip
tools_r05-macosx.zip

usb_d
usb_driver_r03-windows.zip

解决Android屏幕方向变化的问题

作为一个Android开发新手,当我们在开发的时候面对一个大问题

“处理屏幕方向变化“

这个问题的原因是什么?

那么它会导致许多问题如下

   1。只要我们改变方向,它就会创建一个新的Activity
   2。如果在播放音频文件,这将重新载入两次文件,这将同时播放两个同样的歌
   3。导致内存管理问题。
   4。如果你有一个20字段的表单,填写了15个字段,就会丢失15个字段里的内容

那么如何解决这个问题。谷歌在manifest.xml一行代码解决问题

添加这行代码到Activity属性来解决这个问题。
android:configChanges=”orientation”

这样也行
<activityandroid:label=”@string/app_name”android:configChanges=”orientation”

android:name=”.com.androidpeople”>

现在你是完全从这个方向变化问题的自由

Android程序启动画面

public class SplashScreenTest extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    /** set time to splash out */
    final int welcomeScreenDisplay = 3000;
    new Handler().postDelayed(new Runnable(){
       @Override
       public void run() {
           Intent mainIntent = new Intent(SplashScreenTest.this,MainActivity.class);
           startActivity(mainIntent);
           finish();
       }
      }, welcomeScreenDisplay);
    }
}
public class MainActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView textView = new TextView(this);
    textView.setText(“Main Activity”);
    setContentView(textView);
  }
}

svn checkout https://myandroidcode.googlecode.com/svn/trunk/SplashScreenTest

源代码
http://code.google.com/p/myandroidcode/source/browse/trunk/SplashScreenTest
 
 

flex(air) image button

package buttons
{
    import mx.controls.Button;
    
    public class ImageButton extends Button
    {
        [Embed(source=”assets/image/delete-16.png”)]
        private var icon:Class;
        [Embed(source=”assets/image/deleteover.png”)]
        private var overIcon:Class;
        [Embed(source=”assets/image/deletedown.png”)]
        private var downIcon:Class;
        public function ImageButton()
        {
            super();
            this.label = “”;
            this.width = 16;
            this.height = 16;
            this.setStyle(“cornerRadius”,8);
            this.setStyle(“icon”,icon);
            this.setStyle(“downIcon”,downIcon);
            this.setStyle(“overIcon”,overIcon);
            this.setStyle(“upIcon”,icon);
        }
    }
}

应用程序启动前启动画面adobe flex air splash screen

这是一个应用程序启动前的窗口,可以用在多个方面,比如下载资源、检查更新、初始化控件等等

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Window xmlns:fx=”http://ns.adobe.com/mxml/2009″
          xmlns:s=”library://ns.adobe.com/flex/spark”
          xmlns:mx=”library://ns.adobe.com/flex/mx” width=”265″ height=”226″
          systemChrome=”none”
          type=”lightweight” showFlexChrome=”false” transparent=”true”
          verticalScrollPolicy=”off” horizontalScrollPolicy=”off” windowComplete=”init()”>
    <fx:Declarations>
        <!– Place non-visual elements (e.g., services, value objects) here –>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function init():void
            {
                this.nativeWindow.x = Screen.mainScreen.visibleBounds.width/2 – this.width/2;
                this.nativeWindow.y = Screen.mainScreen.visibleBounds.height/2 – this.height/2;
                this.nativeWindow.visible = true;
              
                this.dispatchEvent(new Event(Event.COMPLETE));
                var timer:Timer = new Timer(500,10);
                timer.addEventListener(TimerEvent.TIMER,onTimer);
                timer.start();
            }
            
            private function onTimer(e:TimerEvent):void
            {
                if(lbl.text.length<15)
                    lbl.text += “.”;
                else
                    lbl.text = “download”;
            }
            
            public function showProgress(str:String,num:int):void
            {
                if(!pb.visible)
                    pb.visible = true;
                pb.label = str;
                pb.setProgress(num,100);
            }
        ]]>
    </fx:Script>
    <mx:Canvas width=”266″ height=”227″ borderStyle=”none”>
        <mx:Image source=”@Embed(‘splash-bg.jpg’)” >
            
        </mx:Image>
      
        <s:Label id=”lbl” y=”200″ fontSize=”14″ horizontalCenter=”0″ color=”0xdddddd” text=”download…”>
        </s:Label>
        <mx:ProgressBar id=”pb”  y=”230″ visible=”false” chromeColor=”white”
                        minimum=”0″ maximum=”100″
                        direction=”right” mode=”manual” width=”80%”
                         horizontalCenter=”0″>
            
        </mx:ProgressBar>
    </mx:Canvas>
</mx:Window>

 

 

主程序调用:

this.visible = false;//set app invisible.
splashScreen = new Splash_Window();
splashScreen.addEventListener(Event.COMPLETE,function():void
{
       //闪过之后的处理,splashScreen
});
splashScreen.open();//show splash screen.

 

Android创建sdcard详细图解

Android应用广泛,应用方式灵活,可以在模拟器中进行相应修改实现许多特定的功能需求。我们在这里就先来了解一下Android创建sdcard的具体方法,从中感受一下这一操作系统的相关特性。

Android创建sdcard步骤一、cmd进入tools目录输入mksdcard -l mycard 100M F:mysdcard.img

1. mycard命令可以使用三种尺寸:字节、K和M。如果只使用数字,表示字节。后面还可以跟K,如262144K,也表示256M。

2. mycard建立的虚拟文件最小为8M,也就是说,模拟器只支持大于8M的虚拟文件。

3. -l命令行参数表示虚拟磁盘的卷标,可以没有该参数。

4. 虚拟文件的扩展名可以是任意的,如mycard.abc。

5. mksdcard命令不会自动建立不存在的目录,因此,在执行上面命令之前,要先在当前目录中建立一个card目录。

6. mksdcard命令是按实际大小生成的sdcard虚拟文件。也就是说,生成256M的虚拟文件的尺寸就是256M,如果生成较大的虚拟文件,要看看自己的硬盘空间够不够哦!

Android创建sdcard步骤二、激活sdcard

1.命令行输入:emulator -avd my_android1.5 -sdcard F:mysdcard.img

我在命令行输入激活不了,不知为什么!待解决!

emulator: ERROR: the user data image is used by another emulator. aborting

2.如果在开发环境(Eclipse)中,可以在Run Configuration对话框中设置启动参数

或者在Preferences–>Android–>Launch加入

Android创建sdcard步骤三、sdcard中加入内容

F:android-sdk-windows-1.5_r3tools>adb push E:Xunleigive.mp3 /sdcard/give.mp3