final ActionBar actionBar = getSupportActionBar(); actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24px); actionBar.setDisplayHomeAsUpEnabled(true); // Setting default toolbar title to empty actionBar.setTitle(null);
//set initial title actionBar.setTitle(dateFormatForMonth.format(compactCalendarView.getFirstDayOfCurrentMonth()));
//set title on calendar scroll compactCalendarView.setListener(new CompactCalendarView.CompactCalendarViewListener(){ @Override publicvoidonDayClick(Date dateClicked){
@Override publicvoidonMonthScroll(Date firstDayOfNewMonth){ // Changes toolbar title on monthChange actionBar.setTitle(dateFormatForMonth.format(firstDayOfNewMonth));
}
});
addDummyEvents();
// gotoToday();
}
// Adding dummy events in calendar view for April, may, june 2016 privatevoidaddDummyEvents(){
PieChart mChart; // we're going to display pie chart for school attendance privateint[] yValues ={21,2,2}; private String[] xValues ={"Present Days","Absents","Leaves"};
// colors for different sections in pieChart publicstaticfinalint[] MY_COLORS ={ Color.rgb(84,124,101), Color.rgb(64,64,64), Color.rgb(153,19,0), Color.rgb(38,40,53), Color.rgb(215,60,55) };
// Added My Own colors for(int c : MY_COLORS) colors.add(c);
dataSet.setColors(colors);
// create pie data object and set xValues and yValues and set it to the pieChart PieData data =new PieData(xVals, dataSet); // data.setValueFormatter(new DefaultValueFormatter()); // data.setValueFormatter(new PercentFormatter());
// undo all highlights mChart.highlightValues(null);
// refresh/update pie chart mChart.invalidate();
// animate piechart mChart.animateXY(1400,1400);
// Legends to show on bottom of the graph Legend l = mChart.getLegend(); l.setPosition(Legend.LegendPosition.BELOW_CHART_CENTER); l.setXEntrySpace(7); l.setYEntrySpace(5); }
publicMyValueFormatter(){ mFormat =new DecimalFormat("###,###,##0");// use one decimal if needed }
@Override public String getFormattedValue(float value, Entry entry,int dataSetIndex, ViewPortHandler viewPortHandler){ // write your logic here return mFormat.format(value)+"";// e.g. append a dollar-sign } }
@Override publicvoidonMenuTabReSelected(@IdResint menuItemId){ if(menuItemId == R.id.nav_home){ // The user reselected item number one, scroll your content to top.
} } });
// Setting colors for different tabs when there's more than three of them. // You can set colors for tabs in three different ways as shown below. mBottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(1, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(2, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(3, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(4, ContextCompat.getColor(this, R.color.colorPrimaryDark));
// Set the color for the active tab. Ignored on mobile when there are more than three tabs. // mBottomBar.setActiveTabColor("#009688");
// mBottomBar.selectTabAtPosition(1, true);
setNotificationBadge();
}
privatevoidsetNotificationBadge(){
// Make a Badge for the first tab, with red background color and a value of "13". BottomBarBadge unreadMessages = mBottomBar.makeBadgeForTabAt(4,"#FF0000",10);
// Control the badge's visibility unreadMessages.show(); // unreadMessages.hide();
// Change the displayed count for this badge. unreadMessages.setCount(4);
// Change the show / hide animation duration. unreadMessages.setAnimationDuration(200);
// If you want the badge be shown always after unselecting the tab that contains it. unreadMessages.setAutoShowAfterUnSelection(false); }
// Necessary to restore the BottomBar's state, otherwise we would // lose the current tab on orientation change. mBottomBar.onSaveInstanceState(outState); }