为Android应用程序添加欢迎界面
2015-01-20 14:49
260 查看
欢迎界面代码如下:
[java] view
plaincopy
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设置如下:
[html] view
plaincopy
<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>
主界面的程序代码如下:
[java] view
plaincopy
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;
}
}
主界面的页面设置如下:
[html] view
plaincopy
<?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>
[java] view
plaincopy
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设置如下:
[html] view
plaincopy
<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>
主界面的程序代码如下:
[java] view
plaincopy
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;
}
}
主界面的页面设置如下:
[html] view
plaincopy
<?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>
相关文章推荐
- android应用添加欢迎界面
- Android 为你的应用程序添加快捷方式【优先级高的快捷方式】
- Android 为你的应用程序添加快捷方式【优先级高的快捷方式】
- android的快捷方式——应用程序界面
- 为Android应用程序添加日志记录
- 调用Android系统“应用程序信息(Application Info)”界面
- iPhone和Android应用程序界面对比
- android中跳转到系统管理应用程序界面的方法
- Android Map Api 使用和开发(1) 添加地图和界面
- Android Map Api 使用和开发(1) 添加地图和界面
- 为Android应用程序添加日志记录
- Android 为你的应用程序添加快捷方式【优先级高的快捷方式】
- Android 应用程序中的界面控件与程序控制
- 为Android应用程序添加多媒体
- 调用Android系统“应用程序信息(Application Info)”界面
- Android 为你的应用程序添加快捷方式【优先级高的快捷方式】 推荐
- 怎么给Android添加应用程序
- android 在应用程序中添加快捷图标
- android应用的欢迎启动界面效果
- android应用程序界面不能铺满模拟器的整个屏幕