为Android应用程序添加欢迎界面

欢迎界面代码如下:

[java]  view plain copy
  1. package com.example.weichat.UI;  
  2.   
  3. import android.os.Bundle;  
  4. import android.os.Handler;  
  5. import android.app.Activity;  
  6. import android.content.Intent;  
  7. import android.view.Menu;  
  8. import android.view.MenuItem;  
  9. import android.widget.Toast;  
  10.   
  11. public class WelcomeA extends Activity  
  12. {  
  13.   
  14.     @Override  
  15.     protected void onCreate(Bundle savedInstanceState)  
  16.     {  
  17.         super.onCreate(savedInstanceState);  
  18.         setContentView(R.layout.main);  
  19.         new Handler().postDelayed(new Runnable()  
  20.         {  
  21.   
  22.             @Override  
  23.             public void run()  
  24.             {  
  25.                 // TODO Auto-generated method stub  
  26.                 Intent intent=new Intent(WelcomeA.this,WhatsnewPagesA.class);  
  27.                 startActivity(intent);  
  28.                 WelcomeA.this.finish();  
  29.             }  
  30.         }, 2000);  
  31.     }  
  32.   
  33.       
  34.   
  35. }  

欢迎界面的Layout设置如下:

[html]  view plain copy
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     tools:context=".WelcomeA" >  
  6.   
  7.     <TextView  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content"  
  10.         android:layout_centerHorizontal="true"  
  11.         android:layout_centerVertical="true"  
  12.         android:text="@string/hello_world" />  
  13.   
  14. </RelativeLayout>  

主界面的程序代码如下:

[java]  view plain copy
  1. package com.example.weichat.UI;  
  2.   
  3. import android.app.Activity;  
  4. import android.content.Intent;  
  5. import android.os.Bundle;  
  6. import android.view.Menu;  
  7. import android.view.MenuItem;  
  8. import android.widget.Toast;  
  9.   
  10. public class WhatsnewPagesA extends Activity  
  11. {  
  12.     @Override  
  13.     protected void onCreate(Bundle savedInstanceState)  
  14.     {  
  15.         super.onCreate(savedInstanceState);  
  16.         setContentView(R.layout.start);  
  17.     }  
  18.       
  19.     @Override  
  20.     public boolean onCreateOptionsMenu(Menu menu)  
  21.     {  
  22.         // Inflate the menu; this adds items to the action bar if it is present.  
  23.         getMenuInflater().inflate(R.menu.main, menu);  
  24.         return true;  
  25.     }  
  26.       
  27.     @Override  
  28.     public boolean onOptionsItemSelected(MenuItem item)  
  29.     {  
  30.         //实现点击后查看相关的效果  
  31.         if (item.getItemId()==R.id.menu_settings)  
  32.         {  
  33.             Intent intent = new Intent(this, WhatsnewPagesA.class);  
  34.             startActivity(intent);  
  35.         } else  
  36.         {  
  37.             Toast.makeText(this"该软件由CDersTeam开发,版权归CDersTeam所有,任何侵权行为将负法律责任", Toast.LENGTH_LONG).show();  
  38.         }  
  39.         return true;  
  40.     }  
  41. }  

主界面的页面设置如下:

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <TextView  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="Welcome" />  
  11.   
  12. </LinearLayout>  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值