【开源】Android-PullToNextLayout

Android-PullToNextLayout

使用说明:

activity 的布局

1
2
3
4
5
6
7
8
9
10
11
12
<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=".MainActivity">
 
 
    <com.mingle.pulltonextlayout.PullToNextLayout
        android:id="@+id/pullToNextLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
 
</RelativeLayout>

简单说明 :  布局中只有一个控件PullToNextLayout, 控件中不包含其他组件

java 代码中引用使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 pullToNextLayout= (PullToNextLayout) findViewById(R.id.pullToNextLayout);
        list=new ArrayList<Fragment>();
 
        list.add(new ScrollViewFragment(0));
        list.add(new ScrollViewFragment(1));
        list.add(new ScrollViewFragment(2));
        list.add(new ScrollViewFragment(3));
        list.add(new ScrollViewFragment(4));
        list.add(new ScrollViewFragment(5));
        list.add(new ScrollViewFragment(6));
        list.add(new ScrollViewFragment(7));
//设置适配器
        pullToNextLayout.setAdapter(new PullToNextAdapter(getSupportFragmentManager(), list));
 
       pullToNextLayout.setOnItemSelectListener(new OnItemSelectListener() {
            @Override
            public void onSelectItem(int position, View view) {
 
 
                setTitle(position+1+".0 谷歌仍是毕业生心目中的最佳雇主");
            }
        });
        setTitle(1+".0 谷歌仍是毕业生心目中的最佳雇主");

主要方法:setAdapter(PullToNextAdapter pullToNextAdapter) 主要设置数据源适配器.setAdapter(PullToNextAdapter pullToNextAdapter,int  currentIndex) 设置数据源适配器.并且指定第一个显示的位置.setOnItemSelectListener(OnItemSelectListener onItemSelectListener) 设置选中回调.

DemoFragment 中的主要布局:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
 
    android:background="#ffffff"
    android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:id="@+id/mainLL"
            android:layout_width="fill_parent"
            android:orientation="vertical"
            android:layout_height="fill_parent">
 
    <TextView
        android:id="@+id/titleTV"
        android:layout_width="fill_parent"
        android:padding="4dp"
        android:layout_marginBottom="12dp"
        android:layout_marginTop="12dp"
        android:textSize="20sp"
        android:gravity="center"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/textView"
        android:layout_width="fill_parent"
        android:textSize="16sp"
        android:textColor="#444444"
        android:gravity="center"
        android:padding="4dp"
        android:layout_height="wrap_content" />
            <View
                android:layout_width="fill_parent"
                android:layout_marginTop="30dp"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:layout_height="1px"/>
        </LinearLayout>
 
    </ScrollView>

 

相关代码

  • android-parallax-recyclerview
  • Scrollable
  • 美丽说的---》搭配频道---》的人气的ListView的一屏上下滑动效果是如何实现的?
    网友116.226.3.98 的原帖:
    初步判断是ViewPager做的
 
  • 网友116.226.3.98 2015-04-08
    美丽说的---》搭配频道---》的人气的ListView的一屏上下滑动效果是如何实现的?

posted on 2015-05-05 11:09  wasdchenhao  阅读(154)  评论(0)    收藏  举报

导航