I want to display a View Pager with Date, Week and Month as Title. So i have spinner in the Toolbar with the value(Daily, weekly & Monthly)
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_image"
android:paddingTop="@dimen/app_bar_top_padding"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<Spinner
android:id="@+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
Based upon the selection the Fragments change.
spinner_nav.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapter, View v,
int position, long id) {
// On selecting a spinner item
String item = adapter.getItemAtPosition(position).toString();
switch(position){
case 0:
CommonUtilities.replaceFragment(new WeeklyFragment(), getSupportFragmentManager());
break;
case 1:
CommonUtilities.replaceFragment(new DailyFragment(), getSupportFragmentManager());
break;
case 2:
CommonUtilities.replaceFragment(new MonthlyFragment(), getSupportFragmentManager());
break;
}
For endless page swiping, i used this code from Viewpager in Android to switch between days endlessly.
Problem: I cant able to set page title and Page Select Indicator. How to do this. To achieve this , There is any library available or can help me with this code. Thanks in advance.