Commit ebe534d0 authored by Mrunzzz's avatar Mrunzzz

CalendarView added

parent a2baf562
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" />
<module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" /> <module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" />
<module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" /> <module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" />
<module fileurl="file://D:\IITB-App\IITBApp.iml" filepath="D:\IITB-App\IITBApp.iml" /> <module fileurl="file://D:\IITB-App\IITBApp.iml" filepath="D:\IITB-App\IITBApp.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp.fragments; package in.ac.iitb.gymkhana.iitbapp.fragments;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.TextView;
import android.widget.Toast;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
...@@ -14,7 +19,8 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -14,7 +19,8 @@ import in.ac.iitb.gymkhana.iitbapp.R;
*/ */
public class CalendarFragment extends Fragment { public class CalendarFragment extends Fragment {
private View view;
private Toast toast;
public CalendarFragment() { public CalendarFragment() {
// Required empty public constructor // Required empty public constructor
} }
...@@ -24,7 +30,32 @@ public class CalendarFragment extends Fragment { ...@@ -24,7 +30,32 @@ public class CalendarFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_calendar, container, false); view= inflater.inflate(R.layout.fragment_calendar, container, false);
final CalendarView simpleCalendarView = (CalendarView) view.findViewById(R.id.simpleCalendarView); // get the reference of CalendarView
simpleCalendarView.setFirstDayOfWeek(1); // set Sunday as the first day of the week
simpleCalendarView.setWeekNumberColor(getResources().getColor(R.color.colorCalendarWeek));//setWeekNumberColor
simpleCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
if(toast!=null)
{
toast.cancel();
}
toast=Toast.makeText(getContext(), "Date: ("+dayOfMonth+"/"+(month+1)+"/"+year+")", Toast.LENGTH_LONG);
toast.show();
}
});
return view;
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<corners android:radius="50dip" />
<stroke android:width="0dip" android:color="#667162" />
<gradient android:angle="-90" android:startColor="#FFEA00" android:endColor="#FFEA00" />
</shape>
</item>
</selector>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragments.CalendarFragment"> xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="@style/CalendarTheme"
android:background="#E0E0E0">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<TextView <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="60dp"
android:text="@string/hello_blank_fragment" /> android:background="#00BCD4"/>
<CalendarView
android:id="@+id/simpleCalendarView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusedMonthDateColor="#000000"
android:unfocusedMonthDateColor="#FFFFFF"
android:maxDate="01/01/2019"
android:minDate="01/01/2017"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
android:layout_marginTop="19.5dp"
android:layout_marginBottom="19.5dp"
android:layout_below="@id/simpleCalendarView"/>
<TextView
android:layout_width="120dp"
android:layout_centerHorizontal="true"
android:layout_height="40dp"
android:text="# Events Today"
android:gravity="center"
android:layout_below="@id/simpleCalendarView"
android:background="@drawable/round_text_box"/>
</FrameLayout> </RelativeLayout>
...@@ -4,4 +4,15 @@ ...@@ -4,4 +4,15 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#FFEB3B</item>
<item name="android:colorBackground">?attr/colorButtonNormal</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">?android:attr/colorButtonNormal</item>
</style>
</resources> </resources>
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FF4081</color>
<color name="colorCalendarWeek">#000000</color>
</resources> </resources>
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...@@ -14,4 +14,15 @@ ...@@ -14,4 +14,15 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="CalendarTheme" parent="@style/AppTheme.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#FFEA00</item>
<item name="android:colorBackground">@android:color/darker_gray</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">@android:color/darker_gray</item>
</style>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment