}
package com.neuedu.my12306;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class LoginActivity extends Activity {
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
btnLogin = (Button)findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("My12306","Login Button click");
//显示意图
// Intent intent =new Intent();
// intent.setClass(LoginActivity.this,MainActivity.class);
// startActivity(intent);
// finish();
//隐式意图
Intent intent =new Intent();
intent.setAction("main");
intent.addCategory("bb");
startActivity(intent);
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
}
package com.neuedu.my12306;
import com.neuedu.my12306.my.MyAccountActivity;
import com.neuedu.my12306.my.MyContactActivity;
import com.neuedu.my12306.my.MyPasswordActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class MainActivity extends Activity {
Button btnAccount=null;
Button btnContact=null;
Button btnPassword=null;
Button btnLogout=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
System.out.println();
Log.d("My12306","---onCreate");
btnAccount=(Button)findViewById(R.id.btnAccount);
btnContact=(Button)findViewById(R.id.btnContact);
btnPassword=(Button)findViewById(R.id.btnPassword);
btnLogout=(Button)findViewById(R.id.btnLogout);
MyButtonListener listener=new MyButtonListener();
btnAccount.setOnClickListener(listener);
btnContact.setOnClickListener(listener);
btnPassword.setOnClickListener(listener);
btnLogout.setOnClickListener(listener);
}
//定义一个内部类
class MyButtonListener implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
switch(v.getId()){
case R.id.btnContact:
intent.setClass(MainActivity.this,MyContactActivity.class);
startActivity(intent);
break;
case R.id.btnAccount:
intent.setClass(MainActivity.this,MyAccountActivity.class);
startActivity(intent);
break;
case R.id.btnPassword:
intent.setClass(MainActivity.this,MyPasswordActivity.class);
startActivity(intent);
break;
case R.id.btnLogout:
intent.setClass(MainActivity.this,LoginActivity.class);
startActivity(intent);
break;
}
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.d("My12306","---onDestroy");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.d("My12306","---onPause");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
Log.d("My12306","---onRestart");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.d("My12306","---onResume");
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Log.d("My12306","---onStart");
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onRestoreInstanceState(savedInstanceState);
Log.d("My12306","---onRestoreInstanceState");
}
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
Log.d("My12306","---onSaveInstanceState ");
finish();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Log.d("My12306","---onStop");
}
@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;
}
}
package com.neuedu.my12306.my;
import com.neuedu.my12306.R;
import com.neuedu.my12306.R.layout;
import com.neuedu.my12306.R.menu;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MyAccountActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_account);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my_account, menu);
return true;
}
}
package com.neuedu.my12306;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
//显示意图
// Intent intent =new Intent();
// sleep(10);
// intent.setClass(SplashActivity.this,LoginActivity.class);
// startActivity(intent);
// finish();
final Intent it = new Intent(this, LoginActivity.class); //你要转向的Activity
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
startActivity(it); //执行
}
};
timer.schedule(task, 1000 * 10); //10秒后
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.splash, menu);
return true;
}
}
style="@color/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LoginActivity"
android:background="@drawable/hua3">
android:layout_width="wrap_content"
android:layout_height="35dip"
android:layout_marginLeft="12dip"
android:layout_marginTop="10dip"
android:gravity="bottom"
android:text="@string/zhanghao"
android:textColor="#000000"
android:textSize="18sp" />
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_below="@id/tv_zh"
android:layout_marginLeft="12dip"
android:layout_marginRight="10dip" />
android:layout_width="wrap_content"
android:layout_height="35dip"
android:layout_below="@id/et_zh"
android:layout_marginLeft="12dip"
android:layout_marginTop="10dip"
android:gravity="bottom"
android:text="密码:"
android:textColor="#000000"
android:textSize="18sp" />
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_below="@id/tv_mima"
android:layout_marginLeft="12dip"
android:layout_marginRight="10dip"
android:maxLines="200"
android:password="true"
android:scrollHorizontally="true" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/et_mima"
android:layout_marginLeft="12dip"
android:text="记住密码"
android:textColor="#000000" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cb_mima"
android:layout_marginLeft="12dip"
android:text="自动登录"
android:textColor="#000000" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MyAccountActivity" >
android:layout_height="wrap_content"
android:text="我的账户" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SplashActivity" >
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="74dp"
android:text="正在启动中,请稍候..."
android:textColor="@color/white"
android:textSize="10sp" />
android:versionCode="1"
android:versionName="1.0" >
android:targetSdkVersion="18" />
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:label="@string/app_name" >
android:label="@string/title_activity_login" >
android:label="@string/title_activity_my_account" >
android:label="@string/title_activity_my_contact" >
android:label="@string/title_activity_my_password" >
android:label="@string/title_activity_splash" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/hua1"
android:minWidth="10dip"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >