【开源】AndroidPullMenu

AndroidPullMenu

  •  https://github.com/ShkurtiA/AndroidPullMenu

    介绍:

    下拉选择菜单,当向下滑动的时候菜单选项会逐个被选中。可以用在ScrollView, GridView, ListView中。

    运行效果:

使用说明:

java代码

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
41
42
43
44
45
46
47
48
49
50
51
52
public class MainActivity extends ActionBarActivity implements OnRefreshListener{
 
private PullMenuLayout mPullMenuLayout;
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrollview);
 
    // Now find the PullMenuLayout and set it up
    mPullMenuLayout = (PullMenuLayout) findViewById(R.id.pm_layout);
 
    ArrayList<String> mList = new ArrayList<String>();
    mList.add("Top Stories");
    mList.add("Most Recent");
    mList.add("Interest");
    mList.add("Refresh"); 
 
    // We can now setup the PullMenuLayout
    ActionBarPullMenu.from(this)
            .allChildrenArePullable()
            .listener(this)
            .setup(mPullMenuLayout,android.R.color.white,mList);
}
 
@Override
public void onRefreshStarted(View view, int position, String selectedField) {
        Toast.makeText(MainActivity.this, position + " # "+selectedField, Toast.LENGTH_SHORT).show();
    /**
     * Simulate Refresh with 4 seconds sleep
     */
    new AsyncTask<Void, Void, Void>() {
 
        @Override
        protected Void doInBackground(Void... params) {
            try {
                Thread.sleep(Constants.SIMULATED_REFRESH_LENGTH);
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            return null;
        }
 
        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Notify PullMenuLayout that the refresh has finished
            mPullMenuLayout.setRefreshComplete();
        }
    }.execute();
}   
}

xml代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  <al.shkurti.pullmenu.library.PullMenuLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/pm_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
 
  <ScrollView
      android:id="@+id/scrollview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="8dp"
      android:scrollbarStyle="outsideInset">
 
      <TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/_text"/>
 
  </ScrollView>
 
</al.shkurti.pullmenu.library.PullMenuLayout>

apk下载

http://pan.baidu.com/s/1pndX8 

相关代码

  • android-PullRefreshLayout
  • CRefreshLayout
  • StikkyHeader
  • DragTopLayout
  • PullDownListView

posted on 2015-04-15 09:52  wasdchenhao  阅读(127)  评论(0)    收藏  举报

导航