欢迎界面代码如下:
- package com.example.weichat.UI;
- import android.os.Bundle;
- import android.os.Handler;
- import android.app.Activity;
- import android.content.Intent;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.widget.Toast;
- public class WelcomeA extends Activity
- {
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- new Handler().postDelayed(new Runnable()
- {
- @Override
- public void run()
- {
- // TODO Auto-generated method stub
- Intent intent=new Intent(WelcomeA.this,WhatsnewPagesA.class);
- startActivity(intent);
- WelcomeA.this.finish();
- }
- }, 2000);
- }
- }
欢迎界面的Layout设置如下:
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".WelcomeA" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/hello_world" />
- </RelativeLayout>
主界面的程序代码如下:
- package com.example.weichat.UI;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.widget.Toast;
- public class WhatsnewPagesA extends Activity
- {
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.start);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- //实现点击后查看相关的效果
- if (item.getItemId()==R.id.menu_settings)
- {
- Intent intent = new Intent(this, WhatsnewPagesA.class);
- startActivity(intent);
- } else
- {
- Toast.makeText(this, "该软件由CDersTeam开发,版权归CDersTeam所有,任何侵权行为将负法律责任", Toast.LENGTH_LONG).show();
- }
- return true;
- }
- }
主界面的页面设置如下:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Welcome" />
- </LinearLayout>