android怎么写代码( 三 )


如果你在模拟器中有问题,在你的电脑中移除userdata-qemu.img文件 。这个会让模拟器从一个干净的镜像启动 。
4.android怎么写一个代码可以使得打开一个应用软件时就先出现一个页package com.example.lx56;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity {
private final int SPLASH_DISPLAY_LENGHT = 2000; //延迟2秒
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable(){//延迟发送runnable对象,封装成message
@Override
public void run() {
Intent mainIntent = new Intent(Splash.this,Login.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
}
}
5.Android中怎么用纯代码编写布局很麻烦,总之 。
我以相对布局为例子说明下 btn1 = new Button(this); btn1.setText("我是按钮"); btn1.setId(ID_BTN1); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_WITH_PARENT_TOP); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); // btn1 位于父 View 的顶部,在父 View 中水平居中 rl = new RelativeLayout(this); rl.addView(btn1, lp1 ); //然后在在onCreate()方法里用 setContentView(rl); 。
【android怎么写代码】

android怎么写代码

文章插图