实战 QQ demo源码(本例中有该应用)
服务器端下载:http://download.csdn.net/download/knight_black_bob/9822551
android eclipse 版:http://download.csdn.net/download/knight_black_bob/9822553
android stdio 版本:http://download.csdn.net/download/knight_black_bob/9822556
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageView_firstslide" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" android:src="@drawable/firstslide_8" /> <TextView android:id="@+id/textView_firstslide_btn" android:layout_width="107dp" android:layout_height="32dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="60dp" android:gravity="center" android:background="@drawable/tb" android:text="@string/firstslide_rightnow" android:textColor="#4b4a4a" android:textSize="14sp" /> </RelativeLayout>
activity_firstslide.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.support.v4.view.ViewPager android:id="@+id/vp_firstslider" style="@style/listView_normal_style" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> <LinearLayout android:id="@+id/layout_point_bg" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="20dp" android:gravity="center_vertical" android:orientation="horizontal" > <View android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/firstslide_point" /> <View android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/firstslide_point" /> <View android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/firstslide_point" /> <View android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/firstslide_point" /> </LinearLayout> <LinearLayout android:id="@+id/layout_point" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/layout_point_bg" android:layout_alignLeft="@+id/layout_point_bg" android:layout_alignRight="@+id/layout_point_bg" android:layout_alignTop="@+id/layout_point_bg" android:gravity="center_vertical" android:orientation="horizontal" > <View android:id="@+id/view_point" android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/firstslide_point_selected" /> </LinearLayout> <TextView android:id="@+id/tv_firstslide_pass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="30dp" android:layout_marginRight="30dp" android:gravity="center" android:text="@string/slide_pass" android:textColor="#ffffff" android:textSize="12sp" /> </RelativeLayout>
package com.baoyou.demo.demofirstslide.activity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; import android.text.Html; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.LinearLayout.LayoutParams; import com.baoyou.demo.demofirstslide.MainActivity; import com.baoyou.demo.demofirstslide.R; import com.baoyou.demo.demofirstslide.adapter.FirstSlideAdapter; public class FirstSlideActivity extends Activity implements OnClickListener, OnPageChangeListener { private static final int[] mDataList = { R.drawable.firstslide_1 , R.drawable.firstslide_2, R.drawable.firstslide_3, R.drawable.firstslide_4}; private ViewPager mViewPager; private TextView mTextViewPass; private FirstSlideAdapter mPagerAdapter; private View mViewPoint; private LinearLayout.LayoutParams mLayoutParams; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_firstslide); mViewPager = (ViewPager) this.findViewById(R.id.vp_firstslider); mTextViewPass = (TextView) this.findViewById(R.id.tv_firstslide_pass); mPagerAdapter = new FirstSlideAdapter(mDataList); mTextViewPass.setOnClickListener(this); mPagerAdapter.setOnClickListener(this); mViewPager.setOnPageChangeListener(this); mViewPager.setAdapter(mPagerAdapter); mViewPoint = this.findViewById(R.id.view_point); mLayoutParams = (LayoutParams) mViewPoint.getLayoutParams(); } @Override public void onPageScrollStateChanged(int index) { } @Override public void onPageSelected(int index) { if (index == mPagerAdapter.getCount() - 1) { mTextViewPass.setVisibility(View.GONE); } else { mTextViewPass.setVisibility(View.VISIBLE); } } @Override public void onPageScrolled(int index, float per, int width) { mLayoutParams.leftMargin = Math.round((index + per)* mLayoutParams.width); mViewPoint.setLayoutParams(mLayoutParams); } @Override public void onClick(View v) { startActivity(new Intent(this, MainActivity.class)); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); finish(); } }
package com.baoyou.demo.demofirstslide.adapter; import com.baoyou.demo.demofirstslide.R; import android.support.v4.view.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import android.widget.ImageView.ScaleType; public class FirstSlideAdapter extends PagerAdapter{ private int[] mDataList; private View mView; private OnClickListener mOnClickListener; public void setOnClickListener(OnClickListener onClickListener) { this.mOnClickListener = onClickListener; } public FirstSlideAdapter(int[] mDataList) { this.mDataList = mDataList; } public void setmDataList(int[] mDataList) { this.mDataList = mDataList; } @Override public int getCount() { return mDataList.length; } @Override public boolean isViewFromObject(View view, Object obj) { return view == obj; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public View instantiateItem(ViewGroup container, int position) { if (position == getCount() - 1) { if (mView == null) { mView = LayoutInflater.from(container.getContext()).inflate( R.layout.item_firstslide, null); if(mOnClickListener!=null){ mView.findViewById(R.id.textView_firstslide_btn).setOnClickListener(mOnClickListener); } } container.addView(mView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return mView; } else { ImageView mImageView = new ImageView(container.getContext()); mImageView.setScaleType(ScaleType.FIT_XY); mImageView.setImageResource(mDataList[position]); container.addView(mImageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return mImageView; } } }
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!