欢迎页,引导页和主页

配置

<application
        android:name="com.shipping.application.ShippingApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/NormalTheme" >
        <activity
            android:name="com.shipping.activity.WelcomeActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- GuideActivity -->
        <activity
            android:name="com.shipping.guide.GuideActivity"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait" >
        </activity>

        <!-- GuideViewPagerActivity -->
        <activity
            android:name="com.shipping.guide.GuideViewPagerActivity"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait" >
        </activity>

        <!-- MainActivity -->
        <activity
            android:name="com.shipping.activity.MainActivity"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait" >
        </activity>
        </application>

欢迎页代码

package com.shipping.activity;

import cn.jpush.android.api.JPushInterface;

import com.shipping.R;
import com.shipping.app.App;
import com.shipping.guide.GuideActivity;
import com.shippingframework.activity.BaseActivity;
import com.shippingframework.services.TokenService;
import com.shippingframework.services.UserService;
import com.shippingframework.sharedpreferences.AppSharedPreferences;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class WelcomeActivity extends ShipBaseActivity{

	private AppSharedPreferences appSP;
	 
	// 延迟1秒
	private static final long SPLASH_DELAY_MILLIS = 1000*2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		instance=this;

		setContentView(R.layout.activity_welcome);

		new App(instance);
		appSP=new AppSharedPreferences(instance,AppSharedPreferences.APP_SHAREPRE_FILE);

		ApplicationInit();

		// 使用Handler的postDelayed方法,3秒后执行跳转到MainActivity
		new Handler().postDelayed(new Runnable() {
			public void run() {
				goHome();
			}
		}, SPLASH_DELAY_MILLIS);
		  
	}

	private void ApplicationInit(){

		//获取token
		TokenService tokenService=new  TokenService(instance);
		tokenService.GetAccessToken();

		//系统自动登录
		UserService userService=new UserService(instance);
		userService.AutoLogin();
	}

	private void goHome() {

		if (appSP.getAppIsFirstRun()) {
			appSP.setAppIsFirstRun(false);
			Intent intent = new Intent(WelcomeActivity.this,GuideActivity.class);
			WelcomeActivity.this.startActivity(intent);
			WelcomeActivity.this.finish();
		} else {
			Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
			WelcomeActivity.this.startActivity(intent);
			WelcomeActivity.this.finish();
		}

	}

	@Override
	protected void onResume() {
	super.onResume();
		JPushInterface.onResume(this);
	}

	@Override
	protected void onPause() {
	super.onPause();
		JPushInterface.onPause(this);
	}

}
activity_welcome.xml

<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" >
 
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/welcome"
        android:scaleType="fitCenter" />
 
</RelativeLayout>

引导页代码

package com.shipping.guide;

import com.shipping.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class GuideActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_guide);
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				Intent intent = new Intent(GuideActivity.this,
						GuideViewPagerActivity.class);
				startActivity(intent);
				GuideActivity.this.finish();
			}
		}, 1000);

	}
       

}

activity_guide.xml

<?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" >
    

</LinearLayout>
package com.shipping.guide;

import java.util.ArrayList;

import com.shipping.R;
import com.shipping.activity.MainActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class GuideViewPagerActivity extends Activity {
	/** Called when the activity is first created. */
	private ViewPager mViewPager;
	// private PagerTitleStrip mPagerTitleStrip;
	private ImageView mPageImg;// 动画图片
	private int currIndex = 0;
	private ImageView mPage0;
	private ImageView mPage1;
	private ImageView mPage2;
	//private ImageView mPage3;

	// private ImageView mPage4;
	// private ImageView mPage5;
	// private ImageView mPage6;
	// private ImageView mPage7;
	// private ImageView mPage8;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_guide_viewpager);
		mViewPager = (ViewPager) findViewById(R.id.guide_viewpager);
		mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
		// mPagerTitleStrip = (PagerTitleStrip)findViewById(R.id.pagertitle);

		mPageImg = (ImageView) findViewById(R.id.guide_page_now);

		mPage0 = (ImageView) findViewById(R.id.page0);
		mPage1 = (ImageView) findViewById(R.id.page1);
		mPage2 = (ImageView) findViewById(R.id.page2);
		//mPage3 = (ImageView) findViewById(R.id.page3);
		// mPage4 = (ImageView)findViewById(R.id.page4);
		// mPage5 = (ImageView)findViewById(R.id.page5);
		// mPage6 = (ImageView)findViewById(R.id.page6);
		// mPage7 = (ImageView)findViewById(R.id.page7);
		// mPage8 = (ImageView)findViewById(R.id.page8);

		// 将要分页显示的View装入数组中
		LayoutInflater mLi = LayoutInflater.from(this);
		View view1 = mLi.inflate(R.layout.activity_guide_viewpager_1, null);
		View view2 = mLi.inflate(R.layout.activity_guide_viewpager_2, null);
		View view3 = mLi.inflate(R.layout.activity_guide_viewpager_3, null);
		//View view4 = mLi.inflate(R.layout.activity_app_start_viewpager_end,null);
		// View view5 = mLi.inflate(R.layout.activity_app_start_viewpager_1,
		// null);
		// View view6 = mLi.inflate(R.layout.activity_app_start_viewpager_1,
		// null);
		// View view7 = mLi.inflate(R.layout.activity_app_start_viewpager_1,
		// null);
		// View view8 = mLi.inflate(R.layout.activity_app_start_viewpager_1,
		// null);
		// View view9 = mLi.inflate(R.layout.activity_app_start_viewpager_1,
		// null);

		// 每个页面的view数据
		final ArrayList<View> views = new ArrayList<View>();
		views.add(view1);
		views.add(view2);
		views.add(view3);
		//views.add(view4);
		// views.add(view5);
		// views.add(view6);
		// views.add(view7);
		// views.add(view8);
		// views.add(view9);

		final ArrayList<String> titles = new ArrayList<String>();
		titles.add("①");
		titles.add("②");
		titles.add("③");
		//titles.add("④");
		// titles.add("⑤");
		// titles.add("⑥");
		// titles.add("⑦");
		// titles.add("⑧");
		// titles.add(" ");

		// 填充ViewPager的数据适配器
		PagerAdapter mPagerAdapter = new PagerAdapter() {

			@Override
			public boolean isViewFromObject(View arg0, Object arg1) {
				return arg0 == arg1;
			}

			@Override
			public int getCount() {
				return views.size();
			}

			@Override
			public void destroyItem(View container, int position, Object object) {
				((ViewPager) container).removeView(views.get(position));
			}

			@Override
			public CharSequence getPageTitle(int position) {
				return titles.get(position);
			}

			@Override
			public Object instantiateItem(View container, int position) {
				((ViewPager) container).addView(views.get(position));
				return views.get(position);
			}

			@Override
			public void finishUpdate(View arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void restoreState(Parcelable arg0, ClassLoader arg1) {
				// TODO Auto-generated method stub

			}

			@Override
			public Parcelable saveState() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void startUpdate(View arg0) {
				// TODO Auto-generated method stub

			}
		};

		mViewPager.setAdapter(mPagerAdapter);
	}

	public class MyOnPageChangeListener implements OnPageChangeListener {

		// int one = offset * 2 + bmpW;// 页卡1 -> 页卡2 偏移量
		// int two = one * 2;// 页卡1 -> 页卡3 偏移量
		// int move = 20;

		@Override
		public void onPageSelected(int arg0) {
			Animation animation = null;
			switch (arg0) {
			case 0:
				mPage0.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_now));
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_index));
				if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				} /*
				 * else if (currIndex == 2) { animation = new
				 * TranslateAnimation(20*2, 0, 0, 0); }
				 */
				break;
			case 1:
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_now));
				mPage0.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_index));
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);

				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
			case 2:
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_now));
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.guide_viewpager_index));
				/*
				mPage3.setImageDrawable(getResources().getDrawable(
						R.drawable.app_start_page_index));
						*/
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
				/*
			case 3:
				mPage3.setImageDrawable(getResources().getDrawable(
						R.drawable.app_start_page_now));
				// mPage4.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);

				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
			case 4:
				// mPage4.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_now));
				mPage3.setImageDrawable(getResources().getDrawable(
						R.drawable.app_start_page_index));
				// mPage5.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
			case 5:
				// mPage5.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_now));
				// mPage4.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				// mPage6.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
			case 6:
				// mPage6.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_now));
				// mPage5.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				// mPage7.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;
			case 7:
				// mPage7.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_now));
				// mPage8.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				// mPage6.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} else if (currIndex == arg0 + 1) {
					animation = new TranslateAnimation(20 * (arg0 + 1),
							20 * arg0, 0, 0);
				}
				break;*/
			case 8:
				// mPage8.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_now));
				// mPage7.setImageDrawable(getResources().getDrawable(R.drawable.app_start_page_index));
				if (currIndex == arg0 - 1) {
					animation = new TranslateAnimation(20 * (arg0 - 1),
							20 * arg0, 0, 0);
				} /*
				 * else if (currIndex == arg0+1) { animation = new
				 * TranslateAnimation(20*(arg0+1), 20*arg0, 0, 0); }
				 */
				break;
			}
			currIndex = arg0;
			animation.setFillAfter(true);// True:图片停在动画结束位置
			animation.setDuration(300);
			// mPageImg.startAnimation(animation);
		}

		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {
		}

		@Override
		public void onPageScrollStateChanged(int arg0) {
		}
	}

	public void startbutton(View v) {
		// 获取启动意图
		Intent _intent = getIntent();
		if (_intent != null) {
			boolean isStartClose = _intent.getBooleanExtra("isStartClose",false);
			if (isStartClose) {
				this.finish();
			} else {
				Intent intent = new Intent(GuideViewPagerActivity.this,MainActivity.class);
				startActivity(intent);
				this.finish();
			}
		}else{
			Intent intent = new Intent();
			intent.setClass(GuideViewPagerActivity.this,MainActivity.class);
			startActivity(intent);
			this.finish();
		}

	}
}

activity_guide_viewpager.xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >  

 

    <android.support.v4.view.ViewPager
        android:id="@+id/guide_viewpager"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" > 
        
        
        <android.support.v4.view.PagerTitleStrip
            android:id="@+id/guide_pagertitle"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_gravity="bottom"
            android:background="#0000"
            android:textColor="#ffff" />
    </android.support.v4.view.ViewPager>  
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:gravity="center_horizontal" >       
        
        <ImageView
            android:id="@+id/page0"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_gravity="bottom"
        	android:layout_marginBottom="30dp"        
        
        	android:scaleType="matrix"
        	android:src="@drawable/guide_viewpager_now" />
        <ImageView
            android:id="@+id/page1"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_gravity="bottom"
        	android:layout_marginBottom="30dp"        
        	android:layout_marginLeft="10dp"
        	android:scaleType="matrix"
        	android:src="@drawable/guide_viewpager_index" />
        <ImageView
            android:id="@+id/page2"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_gravity="bottom"
        	android:layout_marginBottom="30dp"        
        	android:layout_marginLeft="10dp"
        	android:scaleType="matrix"
        	android:src="@drawable/guide_viewpager_index" />
        <ImageView
            android:id="@+id/page3"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_gravity="bottom"
        	android:layout_marginBottom="30dp"        
        	android:layout_marginLeft="10dp"
        	android:scaleType="matrix"
        	android:src="@drawable/guide_viewpager_index"
        	android:visibility="gone"
        	 />
               
    </LinearLayout>
    
    <LinearLayout                                  
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >     
        

        <ImageView
        	android:id="@+id/guide_page_now"
        	android:layout_width="wrap_content"
        	android:layout_height="wrap_content"
        	android:layout_gravity="bottom"
        	android:layout_marginBottom="30dp"        
        	android:layout_marginLeft="20dp"
        	android:scaleType="matrix"
        	 />
    </LinearLayout>

    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical" >
        
            <Button
              android:layout_width="wrap_content"
              android:layout_height="32dp"
              android:layout_marginTop="8dp"
              android:layout_marginLeft="8dp"
              android:text="开始体验》"
              android:textSize="10sp"
              android:textColor="#fff"
                  android:visibility="gone"     
              android:background="@color/transparent"   
			  android:onClick="startbutton"/>
        </LinearLayout>
        
    
</FrameLayout>

<!--    <android.support.v4.view.PagerTitleStrip   -->
<!--            android:id="@+id/pagertitle"      -->
<!--            android:layout_width="wrap_content"  -->
<!--            android:layout_height="wrap_content"  -->
<!--            android:layout_gravity="bottom" />  -->

<!--    </android.support.v4.view.ViewPager>  -->

主页代码

package com.shipping.activity;

import java.util.Set;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

import com.shipping.R;
import com.shipping.activity.chat.ChatActivity;
import com.shipping.activity.chat.ChattingActivity;
import com.shipping.activity.ship.MyInquiryPalletDlActivity;
import com.shipping.activity.ship.MyInquiryPalletHzActivity;
import com.shipping.activity.ship.PalletActivity;
import com.shipping.activity.ship.ShipScheduleActivity;
import com.shipping.activity.u.InquiryShipActivity;
import com.shipping.activity.u.uCenterActivity;
import com.shipping.app.App;
import com.shippingframework.sharedpreferences.AppSharedPreferences;
import com.shippingframework.utils.L;
import com.shippingframework.utils.T;

public class MainActivity extends ActivityGroup {

	// main activity
	public static MainActivity instance;

	// LinearLayout
	private LinearLayout mainContainer = null;

	private Intent mainIntent = null;
	private LocalActivityManager localActivityManager = null;
	private TextView appTitle = null;

	// bottom menu layout
	private ImageView btn_boot_pallet_ImageView = null;
	private ImageView btn_boot_shipschedule_ImageView = null;
	private ImageView btn_boot_chat_ImageView = null;
	private ImageView btn_boot_personal_ImageView = null;

	/**
	 * 用户级别的配置文件
	 * */
	private AppSharedPreferences userSP;

	private boolean isSign = false;

	// long
	private long exitTime = 0;

	private int GOTO_LOGIN = 101;

	private String TAG = "";

	private static final int MSG_SET_ALIAS = 1001;
	private static final int MSG_SET_TAGS = 1002;

	private static final int GOTO_LOGIN_ACTIVITY=20;

	private int UserIntId = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		instance = this;
		// new App(instance);
		// App.Logout();

		// 隐藏标题
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		// 设置视图
		setContentView(R.layout.activity_main);

		InitView();
		InitData();
	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		// TODO Auto-generated method stub
		super.onWindowFocusChanged(hasFocus);
		if (hasFocus) {

		}
	}

	/**
	 * 初始化UI
	 */
	protected void InitView() {

		localActivityManager = getLocalActivityManager();

		mainContainer = (LinearLayout) findViewById(R.id.main_container);
		appTitle = (TextView) findViewById(R.id.main_tab_top_title);

		InitTab();
		setContainerView("PalletActivity", PalletActivity.class);
		setMenuIcon("pallet");

	}

	/**
	 * 初始化加载数据
	 */
	protected void InitData() {

		// 检查更新
		// new Handler().postDelayed(new Runnable() {
		// @Override
		// public void run() {
		// AppUpdate appUpdate = new
		// AppUpdate(instance,"com.shipping","manager");
		// appUpdate.checkUpdate();
		// }
		// }, 5000);

		// 获得实例对象
		userSP = new AppSharedPreferences(instance,
				AppSharedPreferences.USER_SHAREPRE_FILE);
		UserIntId = userSP.getUserIntId();
		if (UserIntId > 0) {
			resetAliasAndTags();
		}
	}

	protected void GoLogin() {
		Intent intent = new Intent();
		intent.setClass(instance, LoginActivity.class);
		startActivityForResult(intent, GOTO_LOGIN);

	}

	/**
	 * 初始化TAB
	 * */
	protected void InitTab() {

		// pallet
		btn_boot_pallet_ImageView = (ImageView) findViewById(R.id.bottom_tab_pallet_iv);
		btn_boot_pallet_ImageView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				setMenuIcon("pallet");
				// startActivity(new
				// Intent(MainActivity.this,PalletActivity.class));
				Intent intent = new Intent();
		         intent.setAction("action.palletRefresh");
		         sendBroadcast(intent);
				setContainerView("PalletActivity", PalletActivity.class);
			}
		});

		// ship
		btn_boot_shipschedule_ImageView = (ImageView) findViewById(R.id.bottom_tab_shipschedule_iv);
		btn_boot_shipschedule_ImageView
				.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						setMenuIcon("ship");
						Intent intent = new Intent();
				         intent.setAction("action.shipRefresh");
				         sendBroadcast(intent);
						setContainerView("ShipScheduleActivity",
								ShipScheduleActivity.class);
					}
				});

		// chat
		btn_boot_chat_ImageView = (ImageView) findViewById(R.id.bottom_tab_chat_iv);
		btn_boot_chat_ImageView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				if (App.UserIsLogin()) {
					setMenuIcon("chat");

//					setContainerView("ChatActivity", ChatActivity.class);
					if (userSP.getUserType().equals("HZ")){
						Intent intent = new Intent();
				         intent.setAction("action.hzRefresh");
				         sendBroadcast(intent);
						setContainerView("MyInquiryPalletHzActivity", MyInquiryPalletHzActivity.class);
					}
					if (userSP.getUserType().equals("DL")){
						Intent intent = new Intent();
				         intent.setAction("action.dlRefresh");
				         sendBroadcast(intent);
						setContainerView("MyInquiryPalletDlActivity", MyInquiryPalletDlActivity.class);
					}
					if(userSP.getUserType().equals("CD")){
						Intent intent = new Intent();
				         intent.setAction("action.refresh");
				         sendBroadcast(intent);
						setContainerView("InquiryShipActivity", InquiryShipActivity.class);
					}
				} else {
					T.show(instance, "您尚未登录,请登录后再操作");
					startActivityForResult(new Intent(instance, LoginActivity.class),GOTO_LOGIN_ACTIVITY);
				}
			}
		});

		// 个人
		btn_boot_personal_ImageView = (ImageView) findViewById(R.id.bottom_tab_personal_iv);
		btn_boot_personal_ImageView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				setMenuIcon("personal");
				setContainerView("uCenterActivity", uCenterActivity.class);
			}
		});

	}

	protected void setMenuIcon(String tabIndex) {
		if (tabIndex.equals("pallet")) {
			setTitle("货盘");

			btn_boot_pallet_ImageView
					.setImageResource(R.drawable.btn_home_boot_pallet_pressed);
			btn_boot_shipschedule_ImageView
					.setImageResource(R.drawable.btn_home_boot_ship_normal);
			btn_boot_chat_ImageView
					.setImageResource(R.drawable.btn_home_boot_chat_normal);
			btn_boot_personal_ImageView
					.setImageResource(R.drawable.btn_home_boot_personal_normal);
		} else if (tabIndex.equals("ship")) {
			setTitle("船期");
			btn_boot_pallet_ImageView
					.setImageResource(R.drawable.btn_home_boot_pallet_normal);
			btn_boot_shipschedule_ImageView
					.setImageResource(R.drawable.btn_home_boot_ship_pressed);
			btn_boot_chat_ImageView
					.setImageResource(R.drawable.btn_home_boot_chat_normal);
			btn_boot_personal_ImageView
					.setImageResource(R.drawable.btn_home_boot_personal_normal);
		} else if (tabIndex.equals("chat")) {
			setTitle("聊天");
			btn_boot_pallet_ImageView
					.setImageResource(R.drawable.btn_home_boot_pallet_normal);

			btn_boot_shipschedule_ImageView
					.setImageResource(R.drawable.btn_home_boot_ship_normal);
			btn_boot_chat_ImageView
					.setImageResource(R.drawable.btn_home_boot_chat_pressed);
			btn_boot_personal_ImageView
					.setImageResource(R.drawable.btn_home_boot_personal_normal);
		} else if (tabIndex.equals("personal")) {
			setTitle("个人");
			btn_boot_pallet_ImageView
					.setImageResource(R.drawable.btn_home_boot_pallet_normal);
			btn_boot_shipschedule_ImageView
					.setImageResource(R.drawable.btn_home_boot_ship_normal);
			btn_boot_chat_ImageView
					.setImageResource(R.drawable.btn_home_boot_chat_normal);
			btn_boot_personal_ImageView
					.setImageResource(R.drawable.btn_home_boot_personal_pressed);
		}
	}

	/**
	 * 设置标题
	 * */
	public void setTitle(String title) {
		appTitle.setText(title);
	}

	/**
	 * 设置Container
	 * */
	protected void setContainerView(String id, Class<?> activity) {
		mainContainer.removeAllViews();
		mainIntent = new Intent(this, activity);
		mainIntent.putExtra("VisibilityHeader", false);// True是隐藏 false是不隐藏
		mainIntent.putExtra("IsVisibilityHeaderGoBack", true);// True是隐藏 false是不隐藏
		mainContainer.addView(localActivityManager
				.startActivity(id, mainIntent).getDecorView(),
				new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
						ViewGroup.LayoutParams.MATCH_PARENT));
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// 在首页时才 开启连续两次返回键退出系统功能
		if (keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN) {
			if ((System.currentTimeMillis() - exitTime) > 2000) {
				Toast.makeText(getApplicationContext(), "再按一次退出应用",
						Toast.LENGTH_SHORT).show();
				exitTime = System.currentTimeMillis();
			} else {
				finish();
				System.exit(0);
			}
			return true;
		}

		return super.onKeyDown(keyCode, event);
	}

	private void resetAliasAndTags() {
		L.i(TAG, "----------------------------------resetAliasAndTags begin");

		// reset to jpush
		// JPushInterface.setAliasAndTags(ChattingActivity.this, UserIntId+"",
		// null, new TagAliasCallback() {
		//
		// @Override
		// public void gotResult(int code, String alias, Set<String> tags) {
		// L.i(TAG, "[TagAliasCallback], code: " + code);
		// L.i(TAG, "[TagAliasCallback], alias: " + alias);
		// L.i(TAG, "[TagAliasCallback], tags: " + tags);
		// }
		// });

		UserIntId = userSP.getUserIntId();

		L.i(TAG,
				"----------------------------------resetAliasAndTags UserIntId="
						+ UserIntId);

		// 调用JPush API设置Alias
		jpushHandler.sendMessage(jpushHandler.obtainMessage(MSG_SET_ALIAS,
				UserIntId + ""));

		L.i(TAG, "----------------------------------resetAliasAndTags end");
	}

	private final TagAliasCallback mAliasCallback = new TagAliasCallback() {

		@Override
		public void gotResult(int code, String alias, Set<String> tags) {

			L.i(TAG, "[TagAliasCallback], code: " + code);
			L.i(TAG, "[TagAliasCallback], alias: " + alias);
			L.i(TAG, "[TagAliasCallback], tags: " + tags);

			String logs;
			switch (code) {
			case 0:
				logs = "Set tag and alias success";
				L.i(TAG, logs);
				break;

			case 6002:
				logs = "Failed to set alias and tags due to timeout. Try again after 60s.";
				L.i(TAG, logs);

				jpushHandler.sendMessageDelayed(
						jpushHandler.obtainMessage(MSG_SET_ALIAS, alias),
						1000 * 60);

				break;

			default:
				logs = "Failed with errorCode = " + code;
				L.i(TAG, logs);
			}

			// T.show(getApplicationContext(),logs);
		}

	};

	private final Handler jpushHandler = new Handler() {
		@Override
		public void handleMessage(android.os.Message msg) {
			super.handleMessage(msg);
			switch (msg.what) {
			case MSG_SET_ALIAS:
				L.i(TAG, "Set alias in handler.");
				JPushInterface.setAliasAndTags(getApplicationContext(),
						(String) msg.obj, null, mAliasCallback);
				break;

			// case MSG_SET_TAGS:
			// Log.d(TAG, "Set tags in handler.");
			// JPushInterface.setAliasAndTags(getApplicationContext(), null,
			// (Set<String>) msg.obj, mTagsCallback);
			// break;

			default:
				L.i(TAG, "Unhandled msg - " + msg.what);
			}
		}
	};

}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical" >

    <!-- top -->

    <RelativeLayout
        android:id="@+id/main_tab_top"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@drawable/main_header_relativelayout_bg"
        android:orientation="horizontal"
        android:padding="5dp"
        android:paddingLeft="10dip" 
        android:visibility="gone"
        >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:gravity="center_horizontal|bottom"
            android:visibility="gone" />

        <TextView
            android:id="@+id/main_tab_top_title"
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:layout_centerInParent="true"
            android:layout_gravity="center_vertical|center"
            android:gravity="center_vertical|center"
            android:text="船运在线"
            android:textColor="@color/font_color"
            android:textSize="18dip" />

        <LinearLayout
            android:id="@+id/header_add_linearlayout"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dp"
             android:visibility="gone"
             >

            <ImageView
                android:id="@+id/header_add_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical|center"
                android:background="@drawable/header_icon_add"
                android:padding="10dp" />
        </LinearLayout>
    </RelativeLayout>

    <!-- bottom -->

    <LinearLayout
        android:id="@+id/main_tab_bottom"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/main_bottom_linearlayout_bg"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/bottom_tab_pallet_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal|bottom"
            android:src="@drawable/btn_home_boot_pallet_normal"
            android:textColor="#000000"
            android:textSize="16dip" />

        <ImageView
            android:id="@+id/bottom_tab_shipschedule_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal|bottom"
            android:src="@drawable/btn_home_boot_ship_normal"
            android:textColor="#000000"
            android:textSize="16dip" />

        <ImageView
            android:id="@+id/bottom_tab_chat_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal|bottom"
            android:src="@drawable/btn_home_boot_chat_normal"
            android:textColor="#000000"
            android:textSize="16dip" />

        <ImageView
            android:id="@+id/bottom_tab_personal_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal|bottom"
            android:src="@drawable/btn_home_boot_personal_normal"
            android:textColor="#000000"
            android:textSize="16dip" />
    </LinearLayout>

    <!-- container -->

    <LinearLayout
        android:id="@+id/main_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/main_tab_bottom"
        android:layout_below="@id/main_tab_top"
        android:background="#F4F4F4"
        android:orientation="vertical" >
    </LinearLayout>

</RelativeLayout>
时间: 2024-12-27 10:22:31

欢迎页,引导页和主页的相关文章

开屏三兄弟——闪屏/启动页/引导页

开屏三兄弟——闪屏/启动页/引导页 “开屏页”的交互方式其实并不是完全一样的,也承载着完全不同的功能.我们来了解一下它们的真正用法吧. 特别声明:之前把LaunchScreen和SplashScreen写反了,现已更正,感谢各位大大即时指出错误,希望没有误人子弟,以后会仔细查证后再跟大家分享的.orz,给大家磕一个认错. 同时补充了只有Launch Screen一个页面的启动流程. 原链接:https://www.zcool.com.cn/article/ZNzE3Mzgw.html 原文地址:

Android ViewPager欢迎页+引导页+进入首页

1 import android.app.Activity; 2 import android.content.Intent; 3 import android.content.SharedPreferences; 4 import android.content.SharedPreferences.Editor; 5 import android.os.Bundle; 6 import android.os.Handler; 7 8 /** 欢迎界面 */ 9 public class Wel

闪屏页+引导页

实现原理: 用SharedPreferences实现.创建一个boolean的变量,默认值为true.当判断这个变量是true的时候,说明是第一次运行,就跳转到另一个引导页面,否则进入主页面. 引导页面跳转到最后一张图片时,点击某按钮发生跳转事件,回到MainActivity,此时把变量的值改成false. 引导图效果用ViewPager实现. 下面附上代码: splash.xml: <?xml version="1.0" encoding="utf-8"?&

IOS引导页拨动4张图片最后一张停三秒进入主页

// //  ViewController.m //  LIBAOZHENG0826 // //  Created by 张艳锋 on 15/8/26. //  Copyright (c) 2015年 张艳锋. All rights reserved. // #import "ViewController.h" @interface ViewController () { BOOL isOut; } @end @implementation ViewController - (void

添加数据储存(上一节引导页的问题)

1. 一般的APP都是,最开始启动的时候走引导页,下一次启动的时候就不走引导页,直接就到主页.为了实现这个功能. 这个里面的代码是基于 ViewPager实现引导页 这个来实现的. 创建 Welcome.java 欢迎Activity public class WelcomeAct extends Activity { private boolean isFirstIn = false; private static final int TIME = 2000; private static f

Android仿大众点评引导页(ViewPage)+主页面(Fragment)的实现

大家好,今天主要是实现仿大众点评引导页和主页面以及城市定位的实现,主要使用ViewPager+Fragment+SharedPreferences,实现了第一次打开程序出现引导页,再次打开跳过引导页,这也是一般应用常用的应用基本架构方式.下面首先来看最终实现效果如下图: 1.布局文件说明 1)欢迎页布局文件welcome.xml 2) 引导页布局文件welcome_guide.xml 3)首页布局文件main_home.xml 4)团购布局文件main_tuan.xml 5) 发现布局文件mai

网站的引导页介绍

外贸企业站就是要走出过门,买域名,买空间的.请设计公司.请这请那,一切的努力都是要为了能通过网站给公司带来订单,“一分耕耘一分收获”,但是耕耘了未必就有收获,很多企业站点建好了,可是并没有发现,它所给企业带来的订单.当然,这其中的原因有很多,可能是网站设计不合理?可能是SEO优化没做好?当提到SEO优化的时候,很多人不是很理解,认为那是专门研究SEO的人所讨论的话题,如果你是这样认为的,那么,你就out了,若你想让你的网站在搜索引擎里获得高排名,优化网页时,一定要记住这些重要的环节! 1.少用f

Android学习之加圆点引导页的实现

今天周六,在家好好码代码..... 今天实现的是界面优化的一个简单功能:加圆点的引导页的实现 虽然简单,不过步骤我们还是一步一步来吧 第一步:实现几个View之间的左右滑动,我这次用了四个View(ViewPager) 以下是我的Guide 的布局页面: 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.andr

iOS - GitHub干货分享(APP引导页的高度集成 - DHGuidePageHUD)

好长时间没更新博客, 是时候来一波干货分享了;APP引导页话不多说每一个APP都会用到,分量不重但是不可缺少,不论是APP的首次安装还是版本的更新,首先展现给用户眼前的也就只有它了吧,当然这里讲的不是APP引导页的美化而是APP引导页的高度集成, 一行代码搞定APP引导页是不是太夸张?下面我们就来看一下吧! (一)先上GitHub连接,给大家节省时间(分享是一种美德,Star是一种鼓励; PS:大家别忘了抽出一秒钟的时间点击GitHub右上角的小星星?Star一下, 鼓励一下集成SDK的人??