码迷,mamicode.com
首页 > 移动开发 > 详细

Android -- FlipViewController的使用(jar文件)

时间:2015-03-07 10:12:28      阅读:978      评论:0      收藏:0      [点我收藏+]

标签:

1.  此控件的作用  

  类似于翻书一样,可以上下翻页的控件, 

2.  效果图

  技术分享   上下翻页的效果

3.  实现代码

  

package com.duguang.baseanimation.ui.flip;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.aphidmobile.flip.FlipViewController;
import com.duguang.baseanimation.R;

public class Issue51Activity extends Activity {

	
	/**
	 * 类似于翻书一样,可以上下翻页的控件,详细代码可以查看
	 * https://github.com/openaphid/android-flip/blob/master/FlipView/FlipLibrary/src/com/aphidmobile/flip/FlipViewController.java
	 * 
	 */
	private FlipViewController flipView;

	@ Override
	protected void onCreate ( Bundle savedInstanceState ) {

		super.onCreate ( savedInstanceState );
		setTitle ( R.string.activity_title );

		flipView = new FlipViewController ( this );

		// 设置适配器
		flipView.setAdapter ( new MyBaseAdapter ( this ) );

		setContentView ( flipView );
	}

	@ Override
	protected void onResume ( ) {

		super.onResume ( );
		flipView.onResume ( );
	}

	@ Override
	protected void onPause ( ) {

		super.onPause ( );
		flipView.onPause ( );
	}

	// 自定义适配器
	private static class MyBaseAdapter extends BaseAdapter {

		// 准备加载布局的工具
		private LayoutInflater inflater;

		private MyBaseAdapter (
		               Context context ) {

			inflater = LayoutInflater.from ( context );
		}

		@ Override
		public int getCount ( ) {

			return 3;
		}

		@ Override
		public Object getItem ( int position ) {

			return position;
		}

		@ Override
		public long getItemId ( int position ) {

			return position;
		}

		@ Override
		public View getView ( int position ,
		                              View convertView ,
		                              ViewGroup parent ) {

			if (position == 0) {
				return inflater.inflate ( R.layout.activity_flip_page1 ,
				                              null );
			}
			else if (position == 1) {
				return inflater.inflate ( R.layout.activity_flip_page2 ,
				                              null );
			}
			else {
				return inflater.inflate ( R.layout.activity_flip_page3 ,
				                              null );
			}
		}
	}
}

 

Android -- FlipViewController的使用(jar文件)

标签:

原文地址:http://www.cnblogs.com/SM-t/p/4319817.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!