Android导航页

来源:互联网 发布:游侠网 mac 编辑:程序博客网 时间:2024/05/19 10:38

public class WelcomeActivity extends AppCompatActivity {
private static final int TIME = 30000;
private static final int GO_HOME = 1000;
private static final int GO_GUIDE = 1001;
private boolean isFirstIn = false;
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case GO_HOME:
goHome();
break;
case GO_GUIDE:
goGuide();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
handler.sendEmptyMessageDelayed(GO_HOME,TIME);
init();
}
private void init(){
//执行成功的话,会将数据保存在homeTest.xml文件中
SharedPreferences preferences = getSharedPreferences(“homeTest”,MODE_PRIVATE);
//第一个参数是key,第二个参数是默认值
isFirstIn = preferences.getBoolean(“isFirstIn”,true);
if (!isFirstIn){
handler.sendEmptyMessageDelayed(GO_HOME,TIME);
}
else {
handler.sendEmptyMessageDelayed(GO_GUIDE,TIME);
//利用edit()方法获取Editor对象
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(“isFirstIn”,false);
editor.commit();
}
}
private void goHome(){
Intent intent = new Intent(WelcomeActivity.this,LoginActivity.class);
startActivity(intent);
finish(); }
private void goGuide(){
Intent intent = new Intent(Welcome.this,Guide.class); startActivity(intent);
finish();
}
}

android:scaleType="fitXY"屏幕自适应

屏幕自适应xml属性

详文

0 0