From a586191619f47f2dd1e63fd2b81f7765b7e3374c Mon Sep 17 00:00:00 2001 From: SpecialCyci Date: Thu, 29 May 2014 23:45:28 +0800 Subject: [PATCH] Add calendar listview demo. --- README.md | 2 +- .../com/special/ResideMenu/ResideMenu.java | 4 +- ResideMenuDemo/AndroidManifest.xml | 2 +- ResideMenuDemo/res/layout/calendar.xml | 13 ++---- .../ResideMenuDemo/CalendarFragment.java | 44 ++++++++++++++++++- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e10cda7..fb5e70e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This copy is the demo. ## Version Migration -#### Upgrading to `1.4` from `1.3`, `1.2`, `1.1`, `1.0` +#### Upgrading to `v1.4` from `v1.3`, `v1.2`, `v1.1`, `v1.0` Duplicate the followed code in dispatchTouchEvent() of Activity, replace the old `dispatchTouchEvent()` code. diff --git a/ResideMenu/src/com/special/ResideMenu/ResideMenu.java b/ResideMenu/src/com/special/ResideMenu/ResideMenu.java index 92f5c28..ce1b2b3 100644 --- a/ResideMenu/src/com/special/ResideMenu/ResideMenu.java +++ b/ResideMenu/src/com/special/ResideMenu/ResideMenu.java @@ -331,7 +331,7 @@ public void onClick(View view) { private Animator.AnimatorListener animationListener = new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { - if (isOpened){ + if (isOpened()){ scrollViewMenu.setVisibility(VISIBLE); if (menuListener != null) menuListener.openMenu(); @@ -341,7 +341,7 @@ public void onAnimationStart(Animator animation) { @Override public void onAnimationEnd(Animator animation) { // reset the view; - if(isOpened){ + if(isOpened()){ viewActivity.setTouchDisable(true); viewActivity.setOnClickListener(viewActivityOnClickListener); }else{ diff --git a/ResideMenuDemo/AndroidManifest.xml b/ResideMenuDemo/AndroidManifest.xml index 7f55603..a57b655 100644 --- a/ResideMenuDemo/AndroidManifest.xml +++ b/ResideMenuDemo/AndroidManifest.xml @@ -7,7 +7,7 @@ android:targetSdkVersion="17"/> diff --git a/ResideMenuDemo/res/layout/calendar.xml b/ResideMenuDemo/res/layout/calendar.xml index e8ec086..494ef6e 100644 --- a/ResideMenuDemo/res/layout/calendar.xml +++ b/ResideMenuDemo/res/layout/calendar.xml @@ -4,13 +4,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - - - + \ No newline at end of file diff --git a/ResideMenuDemo/src/com/special/ResideMenuDemo/CalendarFragment.java b/ResideMenuDemo/src/com/special/ResideMenuDemo/CalendarFragment.java index a4cb4bb..492ac58 100644 --- a/ResideMenuDemo/src/com/special/ResideMenuDemo/CalendarFragment.java +++ b/ResideMenuDemo/src/com/special/ResideMenuDemo/CalendarFragment.java @@ -5,6 +5,12 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.SimpleAdapter; + +import java.util.ArrayList; +import java.util.List; /** * User: special @@ -14,9 +20,45 @@ */ public class CalendarFragment extends Fragment { + private View parentView; + private ListView listView; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.calendar, container, false); + parentView = inflater.inflate(R.layout.calendar, container, false); + listView = (ListView) parentView.findViewById(R.id.listView); + initView(); + return parentView; } + private void initView(){ + ArrayAdapter arrayAdapter = new ArrayAdapter( + getActivity(), + android.R.layout.simple_list_item_1, + getCalendarData()); + listView.setAdapter(arrayAdapter); + } + + private ArrayList getCalendarData(){ + ArrayList calendarList = new ArrayList(); + calendarList.add("New Year's Day"); + calendarList.add("St. Valentine's Day"); + calendarList.add("Easter Day"); + calendarList.add("April Fool's Day"); + calendarList.add("Mother's Day"); + calendarList.add("Memorial Day"); + calendarList.add("National Flag Day"); + calendarList.add("Father's Day"); + calendarList.add("Independence Day"); + calendarList.add("Labor Day"); + calendarList.add("Columbus Day"); + calendarList.add("Halloween"); + calendarList.add("All Soul's Day"); + calendarList.add("Veterans Day"); + calendarList.add("Thanksgiving Day"); + calendarList.add("Election Day"); + calendarList.add("Forefather's Day"); + calendarList.add("Christmas Day"); + return calendarList; + } }