Database locking

https://github.com/SQLDroid/SQLDroid/wiki/Tips-and-tricks-(including-database-locking)

IntroScrollView

public class IntroScrollView extends ScrollView{

// private Context mContext;
private ScrollViewListener scrollViewListener = null;
public interface ScrollViewListener {

   void onScrollChanged(IntroScrollView scrollView, int x, int y, int oldx, int oldy);

}
public IntroScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
// mContext = context;
}

public IntroScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
// mContext = context;
}

public IntroScrollView(Context context) {
super(context);
// TODO Auto-generated constructor stub
// mContext = context;
}

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// TODO Auto-generated method stub
super.onScrollChanged(l, t, oldl, oldt);
if(scrollViewListener != null) {
            scrollViewListener.onScrollChanged(this, l, t, oldl, oldt);
        }
}
public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }
}

RelativeLayoutDetectKeyBoard

public class RelativeLayoutDetectKeyBoard extends RelativeLayout {

Rect rect = new Rect();
public RelativeLayoutDetectKeyBoard(Context context,
AttributeSet attrs) {
super(context, attrs);
}

public interface Listener {
public void onSoftKeyboardShown(boolean isShowing);
}

private Listener listener;

public void setListener(Listener listener) {
this.listener = listener;
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = MeasureSpec.getSize(heightMeasureSpec);
Activity activity = (Activity) getContext();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
int statusBarHeight = rect.top;
int screenHeight = activity.getWindowManager().getDefaultDisplay()
.getHeight();
int diff = (screenHeight - statusBarHeight) - height;
if (listener != null) {
listener.onSoftKeyboardShown(diff > 128); // assume all soft
// keyboards are at
// least 128 pixels high
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

}

Validation in android

import java.util.regex.Pattern;


import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.EditText;

public class ValidationManager {

// a result of the validation of the fields from the form
public static final int ALERT_OK = 0; // parameters is entered correctly
public static final int ALERT_LOGIN = 1; // incorrect login
public static final int ALERT_PASSWORD = 2; // incorrect password
public static final int ALERT_PASSWORD_REPEAT = 3; // incorrect password
public static final int ALERT_FULLNAME = 4; // incorrect fullname
public static final int ALERT_EMAIL = 5; // incorrect email
public static final int ALERT_FILL_ALL_FIELDS = 6;
public static final int ALERT_PASSWORD_DIDNOT_MATCH = 7;
public static final int ALERT_FIRST_NAME = 8;
public static final int ALERT_LAST_NAME = 9;
public static final int ALERT_COUNTRY = 10;
public static final int ALERT_CITY = 11;
public static final int ALERT_ZIP_CODE = 12;
public static final int ALERT_PASSWORD_LENGTH = 13;
public static final int ALERT_INVALID_EMAIL = 14;
public static final int ALERT_PUBLIC_NAME = 15;
public static final int ALERT_PHONE = 16;

//  An email-validation using the regular expression
public final static Pattern EMAIL_ADDRESS_PATTERN = Pattern
.compile("[a-zA-Z0-9+._%-+]{1,256}" + "@"
+ "[a-zA-Z0-9][a-zA-Z0-9-]{0,64}" + "(" + "."
+ "[a-zA-Z0-9][a-zA-Z0-9-]{0,25}" + ")+");

public static boolean checkEmail(String email) {
   return EMAIL_ADDRESS_PATTERN.matcher(email).matches();
}


public static int checkInputParameters(EditText login, EditText pass) {

String fieldLogin = login.getText().toString();
String fieldPass = pass.getText().toString();

if (fieldLogin.length() == 0) {
return ALERT_LOGIN;
}

if (fieldPass.length() == 0) {
return ALERT_PASSWORD;
}

return ALERT_OK;
}

public static int checkInputParameters(EditText login, EditText pass, EditText pass2,
EditText fullname) {

String fieldLogin = login.getText().toString();
String fieldPass = pass.getText().toString();
String fieldPass2 = pass2.getText().toString();
String fieldFullname = fullname.getText().toString();

if (fieldFullname.length() == 0) {
return ALERT_FULLNAME;
}

if (fieldLogin.length() == 0) {
return ALERT_LOGIN;
}

if (fieldPass.length() == 0) {
return ALERT_PASSWORD;
}

if(!fieldPass.equals(fieldPass2)){
return ALERT_PASSWORD_REPEAT;
}

return ALERT_OK;
}

public static int checkInputParameters(String email, String pass, String conPass, String firstName,
String lastName, String publicName, String phone) {

if(email.equalsIgnoreCase("") && pass.equalsIgnoreCase("") && conPass.equalsIgnoreCase("")
&& firstName.equalsIgnoreCase("") && lastName.equalsIgnoreCase("") && publicName.equalsIgnoreCase("")
&& phone.equalsIgnoreCase("")){

return ALERT_FILL_ALL_FIELDS;
}
if (publicName.length() == 0) {
return ALERT_PUBLIC_NAME;
}
if (firstName.length() == 0) {
return ALERT_FIRST_NAME;
}

if (lastName.length() == 0) {
return ALERT_LAST_NAME;
}
if (email.length() == 0) {
return ALERT_EMAIL;
}

if(email.length() > 0){
if(!checkEmail(email)){
return ALERT_INVALID_EMAIL;
}
}

if (phone.length() == 0) {
return ALERT_PHONE;
}
if (pass.length() == 0) {
return ALERT_PASSWORD;
}

if (pass.length() > 0 && pass.length() < 6) {
return ALERT_PASSWORD_LENGTH;
}

if (conPass.length() == 0) {
return ALERT_PASSWORD_REPEAT;
}

if(!pass.equals(conPass)){
return ALERT_PASSWORD_DIDNOT_MATCH;
}

return ALERT_OK;
}
}




Usage:

int validationResult = ValidationManager.checkInputParameters(
strEmail, strPassword, strConfirmPass, strFirstName,
strLastName, strPublicName, strPhone);


if (validationResult != ValidationManager.ALERT_OK) {

switch (validationResult) {
case ValidationManager.ALERT_FILL_ALL_FIELDS:
alertMessage = "Please fill all fields.";
break;
case ValidationManager.ALERT_PUBLIC_NAME:
alertMessage = "Please enter your Username.";
break;
case ValidationManager.ALERT_FIRST_NAME:
alertMessage = "Please enter first name.";
break;

case ValidationManager.ALERT_LAST_NAME:
alertMessage = "Please enter last name.";
break;

case ValidationManager.ALERT_EMAIL:
alertMessage = "Email can not be empty.";
break;

case ValidationManager.ALERT_INVALID_EMAIL:
alertMessage = "Please enter a valid email address.";
break;

case ValidationManager.ALERT_PHONE:
alertMessage = "Please enter your phone no";
break;

case ValidationManager.ALERT_PASSWORD:
alertMessage = "Password can not be empty.";
break;

case ValidationManager.ALERT_PASSWORD_REPEAT:
alertMessage = "Repeat password can not be empty.";
break;

case ValidationManager.ALERT_PASSWORD_LENGTH:
alertMessage = "Password is too short.[min 6 characters].";
break;

case ValidationManager.ALERT_PASSWORD_DIDNOT_MATCH:
alertMessage = "Password didn't match.";
break;

}

AlertManager
.showAlert(CreateAccount.this, alertMessage)

samples2

public class CalendarDayMarker {
private int _year;
private int _month;
private int _day;
private int _color;

public CalendarDayMarker(int year, int month, int day, int color) {
init(year, month, day, color);
}

public CalendarDayMarker(Date d, int color) {
Calendar c = Calendar.getInstance();
c.setTime(d);

init(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), color);
}

public CalendarDayMarker(Calendar c, int color) {
init(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), color);
}

private void init(int year, int month, int day, int color) {
_year = year;
_month = month;
_day = day;
_color = color;
}

public void setYear(int year) {
_year = year;
}

public int getYear() {
return _year;
}

public void setMonth(int month) {
_month = month;
}

public int getMonth() {
return _month;
}

public void setDay(int day) {
_day = day;
}

public int getDay() {
return _day;
}

public void setColor(int color) {
_color = color;
}

public int getColor() {
return _color;
}
}

//-----------------------------------------

public class CalendarTagInfo {
private int _monthAdd;
private int _day;
private boolean _isEventDay;
private int _drawableId;
public void setMonthAdd(int monthadd){
_monthAdd = monthadd;
}
public void setDay(int day){
_day = day;
}
public void setIsEventDay(boolean isEventday){
_isEventDay = isEventday;
}
public void setDrawableId(int id){
_drawableId = id;
}
public int getMonthAdd(){
return _monthAdd;
}
public int getDay(){
return _day;
}
public boolean getIsEventDay(){
return _isEventDay;
}
public int drawableId(){
return _drawableId;
}

}


//----------------------------------------------------

public class CalendarView extends LinearLayout {
private CheckedTextView _txtprev;
public CalendarView(Context context) {
super(context);
init(context);
}

public CalendarView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}

public interface OnMonthChangedListener {
public void onMonthChanged(CalendarView view);
}

public void setOnMonthChangedListener(OnMonthChangedListener l) {
_onMonthChangedListener = l;
}

public interface OnSelectedDayChangedListener {
public void onSelectedDayChanged(CalendarView view);
}

public void setOnSelectedDayChangedListener(OnSelectedDayChangedListener l) {
_onSelectedDayChangedListener = l;
}

public Calendar getVisibleStartDate() {
return _calendar.getVisibleStartDate();
}

public Calendar getVisibleEndDate() {
return _calendar.getVisibleEndDate();
}

public Calendar getSelectedDay() {
return _calendar.getSelectedDay();
}

public void setDaysWithEvents(CalendarDayMarker[] markers) {
int hits = 0;
int dayItemsInGrid = 42;
int row = 1; // Skip weekday header row
int col = 0;
Calendar tempCal = _calendar.getVisibleStartDate();

for(int i = 0; i < dayItemsInGrid; i++) {
if(hits == markers.length) //If we've already marked as many days as we have markers
break;
TableRow tr = (TableRow) _days.getChildAt(row);
LinearLayout rl = (LinearLayout) tr.getChildAt(col);
CheckedTextView tv = (CheckedTextView) rl.getChildAt(0);
// int[] tag = (int[]) tv.getTag();
int day = ((CalendarTagInfo) tv.getTag()).getDay();
for (int j = 0; j < markers.length; j++) {
CalendarDayMarker m = markers[j];
if(m==null) continue;
if (tempCal.get(Calendar.YEAR) == m.getYear() && tempCal.get(Calendar.MONTH) == m.getMonth() && day == m.getDay()) {
CalendarTagInfo info = (CalendarTagInfo) tv.getTag();
Calendar cal = Calendar.getInstance();
info.setIsEventDay(true);
tv.setTag(info);
if(cal.get(Calendar.MONTH) == m.getMonth() && cal.get(Calendar.DAY_OF_MONTH)==m.getDay()){
tv.setBackgroundResource(R.drawable.ic_calender_blue_on);
_txtprev = tv;
Log.e("", _txtprev+"initial");
}
else{
tv.setBackgroundResource(m.getColor());
}
hits++;
break;
}
}
tempCal.add(Calendar.DAY_OF_MONTH, 1);
col++;

if (col == 7) {
col = 0;
row++;
}
}
}

public void setListViewItems(View[] views) {
_events.removeAllViews();

for (int i = 0; i < views.length; i++) {
_events.addView(views[i]);
}
}

private void init(Context context) {
View v = LayoutInflater.from(context).inflate(R.layout.calendar, this, true);

_calendar = new CalendarWrapper();
_days = (TableLayout) v.findViewById(R.id.days);
_months = (TableLayout) v.findViewById(R.id.months);
_years = (TableLayout) v.findViewById(R.id.years);
_up = (Button) v.findViewById(R.id.up);
_prev = (Button) v.findViewById(R.id.previous);
_next = (Button) v.findViewById(R.id.next);
_events = (LinearLayout) v.findViewById(R.id.events);

refreshCurrentDate();

// Days Table
String[] shortWeekDayNames = _calendar.getShortDayNames();

for (int i = 0; i < 7; i++) { // Rows
TableRow tr = (TableRow) _days.getChildAt(i);

for (int j = 0; j < 7; j++) { // Columns
Boolean header = i == 0; // First row is weekday headers
LinearLayout rl = (LinearLayout) tr.getChildAt(j);
CheckedTextView tv = (CheckedTextView) rl.getChildAt(0);

if (header)
tv.setText(shortWeekDayNames[j]);
else
tv.setOnClickListener(_dayClicked);
}
}

refreshDayCells();

// Months Table
String[] shortMonthNames = _calendar.getShortMonthNames();
int monthNameIndex = 0;

for (int i = 0; i < 3; i++) { // Rows
TableRow tr = (TableRow) _months.getChildAt(i);

for (int j = 0; j < 4; j++) { // Columns
TextView tv = (TextView) tr.getChildAt(j);
tv.setOnClickListener(_monthClicked);
tv.setText(shortMonthNames[monthNameIndex]);
tv.setTag(monthNameIndex);

monthNameIndex++;
}
}

// Years Table
for (int i = 0; i < 3; i++) { // Rows
TableRow tr = (TableRow) _years.getChildAt(i);

for (int j = 0; j < 4; j++) { // Columns
TextView tv = (TextView) tr.getChildAt(j);
tv.setOnClickListener(_yearClicked);
}
}

// Listeners
_calendar.setOnDateChangedListener(_dateChanged);
// _up.setOnClickListener(_upClicked);
_prev.setOnClickListener(_incrementClicked);
_next.setOnClickListener(_incrementClicked);

setView(MONTH_VIEW);
}

private OnDateChangedListener _dateChanged = new OnDateChangedListener() {
@Override
public void onDateChanged(CalendarWrapper sc) {
Boolean monthChanged = _currentYear != sc.getYear() || _currentMonth != sc.getMonth();
if (monthChanged) {
refreshDayCells();
invokeMonthChangedListener();
}

refreshCurrentDate();
refreshUpText();
}
};

private OnClickListener _incrementClicked = new OnClickListener() {
@Override
public void onClick(View v) {
int inc = (v == _next ? 1 : -1);

if (_currentView == MONTH_VIEW)
_calendar.addMonth(inc);
else if (_currentView == DAY_VIEW) {
_calendar.addDay(inc);
invokeSelectedDayChangedListener();
}
else if (_currentView == YEAR_VIEW) {
_currentYear += inc;
refreshUpText();
}
}
};

private OnClickListener _dayClicked = new OnClickListener() {
@Override
public void onClick(View v) {
CalendarTagInfo info = (CalendarTagInfo) v.getTag(); 
_calendar.addMonthSetDay(info.getMonthAdd(), info.getDay());
invokeSelectedDayChangedListener();
CheckedTextView textview = (CheckedTextView)v;
if(_txtprev!=null){
Log.e("", _txtprev.getText().toString());
info = (CalendarTagInfo) _txtprev.getTag();
Calendar cal = Calendar.getInstance();
if(info.getMonthAdd()!=0){
cal.add(Calendar.MONTH, info.getMonthAdd());
}
cal.set(Calendar.DAY_OF_MONTH, info.getDay());
if(info.getIsEventDay()){
if((Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH))&&
(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH))){
_txtprev.setBackgroundResource(R.drawable.ic_calender_gray_on);
}
else{
_txtprev.setBackgroundResource(R.drawable.ic_calender_white_on);
}
}
else{
if((Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH))&&
(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH))){
_txtprev.setBackgroundResource(R.drawable.ic_calender_today);
}
else {_txtprev.setBackgroundDrawable(null);}
}
}
_txtprev = textview;
info = (CalendarTagInfo) textview.getTag();
if(info.getIsEventDay()){
textview.setBackgroundResource(R.drawable.ic_calender_blue_on);
}
else{
_txtprev.setBackgroundResource(R.drawable.ic_calender_selection);
}
}
};

private OnClickListener _monthClicked = new OnClickListener() {
@Override
public void onClick(View v) {
_calendar.setYearAndMonth(_currentYear, (Integer) v.getTag());
setView(MONTH_VIEW);
}
};

private OnClickListener _yearClicked = new OnClickListener() {
@Override
public void onClick(View v) {
_currentYear = (Integer) v.getTag();
setView(YEAR_VIEW);
}
};

/* private OnClickListener _upClicked = new OnClickListener() {
@Override
public void onClick(View v) {
setView(_currentView + 1);
}
};
*/
private void refreshDayCells() {
int[] dayGrid = _calendar.get7x6DayArray();
int monthAdd = -1;
int row = 1; // Skip weekday header row
int col = 0;

for (int i = 0; i < dayGrid.length; i++) {
int day = dayGrid[i];

if (day == 1)
monthAdd++;

TableRow tr = (TableRow) _days.getChildAt(row);
LinearLayout rl = (LinearLayout)tr.getChildAt(col);
CheckedTextView tv = (CheckedTextView) rl.getChildAt(0);
//Clear current markers, if any.
tv.setBackgroundDrawable(null);
// tv.setChecked(false);
tv.setText(dayGrid[i] + "");

if (monthAdd == 0){
tv.setTextColor(Color.LTGRAY);//current months day color
if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == dayGrid[i]){
tv.setBackgroundResource(R.drawable.ic_calender_selection);
_txtprev = tv;
}
}
else
tv.setTextColor(Color.DKGRAY);//next or prev months day color
CalendarTagInfo info = new CalendarTagInfo();
info.setMonthAdd(monthAdd);
info.setDay(dayGrid[i]);
tv.setTag(info);

col++;

if (col == 7) {
col = 0;
row++;
}
}
}

private void setView(int view) {
if (_currentView != view) {
_currentView = view;
_events.setVisibility(_currentView == DAY_VIEW ? View.VISIBLE : View.GONE);
_years.setVisibility(_currentView == DECADE_VIEW ? View.VISIBLE : View.GONE);
_months.setVisibility(_currentView == YEAR_VIEW ? View.VISIBLE : View.GONE);
_days.setVisibility(_currentView == MONTH_VIEW ? View.VISIBLE : View.GONE);
_up.setEnabled(_currentView != YEAR_VIEW);
//line changed 
_events.setVisibility(View.GONE);
refreshUpText();
}
}

private void refreshUpText() {
switch (_currentView) {
case MONTH_VIEW:
_up.setText(_calendar.toString("MMMM"));
break;
case YEAR_VIEW:
_up.setText(_currentYear + "");
break;
case CENTURY_VIEW:
_up.setText("CENTURY_VIEW");
break;
case DECADE_VIEW:
_up.setText("DECADE_VIEW");
break;
case DAY_VIEW:
_up.setText(_calendar.toString("EEEE, MMMM dd, yyyy"));
break;
case ITEM_VIEW:
_up.setText("ITEM_VIEW");
break;
default:
break;
}
}
public void setCalenderViewToNormal(){
setView(MONTH_VIEW);
}

private void refreshCurrentDate() {
_currentYear = _calendar.getYear();
_currentMonth = _calendar.getMonth();
_calendar.getDay();
}

private void invokeMonthChangedListener() {
if (_onMonthChangedListener != null)
_onMonthChangedListener.onMonthChanged(this);
}

private void invokeSelectedDayChangedListener() {
if (_onSelectedDayChangedListener != null)
_onSelectedDayChangedListener.onSelectedDayChanged(this);
}

private final int CENTURY_VIEW = 5;
private final int DECADE_VIEW = 4;
private final int YEAR_VIEW = 3;
private final int MONTH_VIEW = 2;
private final int DAY_VIEW = 1;
private final int ITEM_VIEW = 0;

private CalendarWrapper _calendar;
private TableLayout _days;
private TableLayout _months;
private TableLayout _years;
private LinearLayout _events;
private Button _up;
private Button _prev;
private Button _next;
private OnMonthChangedListener _onMonthChangedListener;
private OnSelectedDayChangedListener _onSelectedDayChangedListener;
private int _currentView;
private int _currentYear;
private int _currentMonth;
}


//-------------------------------------------

public class CalendarWrapper {
public interface OnDateChangedListener {
public void onDateChanged(CalendarWrapper sc);
}

public CalendarWrapper() {
_calendar = Calendar.getInstance();
_shortDayNames = new String[_calendar.getActualMaximum(Calendar.DAY_OF_WEEK)];
_shortMonthNames = new String[_calendar.getActualMaximum(Calendar.MONTH) + 1]; // Months are 0-based so size is Max + 1
for (int i = 0; i < _shortDayNames.length; i++) {
_shortDayNames[i] = DateUtils.getDayOfWeekString(i + 1, DateUtils.LENGTH_SHORT);
}
for (int i = 0; i < _shortMonthNames.length; i++) {
_shortMonthNames[i] = DateUtils.getMonthString(i, DateUtils.LENGTH_SHORT);
}
}

public int getYear() {
return _calendar.get(Calendar.YEAR);
}

public int getMonth() {
return _calendar.get(Calendar.MONTH);
}
public int getDayOfWeek() {
return _calendar.get(Calendar.DAY_OF_WEEK);
}
public int getDay() {
return _calendar.get(Calendar.DAY_OF_MONTH);
}

public void setYear(int value) {
_calendar.set(Calendar.YEAR, value);
invokeDateChangedListener();
}
public void setYearAndMonth(int year, int month) {
_calendar.set(Calendar.YEAR, year);
_calendar.set(Calendar.MONTH, month);
invokeDateChangedListener();
}

public void setMonth(int value) {
_calendar.set(Calendar.MONTH, value);
invokeDateChangedListener();
}

public void setDay(int value) {
_calendar.set(Calendar.DAY_OF_MONTH, value);
invokeDateChangedListener();
}
public void addYear(int value) {
if(value != 0) {
_calendar.add(Calendar.YEAR, value);
invokeDateChangedListener();
}
}

public void addMonth(int value) {
if(value != 0) {
_calendar.add(Calendar.MONTH, value);
invokeDateChangedListener();
}
}
public void addMonthSetDay(int monthAdd, int day) {
_calendar.add(Calendar.MONTH, monthAdd);
_calendar.set(Calendar.DAY_OF_MONTH, day);
invokeDateChangedListener();
}

public void addDay(int value) {
if(value != 0) {
_calendar.add(Calendar.DAY_OF_MONTH, value);
invokeDateChangedListener();
}
}

public String[] getShortDayNames() {
return _shortDayNames;
}

public String[] getShortMonthNames() {
return _shortMonthNames;
}

public int[] get7x6DayArray() {
_visibleStartDate = null;
_visibleEndDate = null;
int[] days = new int[42];

Calendar tempCal = (Calendar) _calendar.clone();
tempCal.set(Calendar.DAY_OF_MONTH, 1);
int dayOfWeekOn1st = tempCal.get(Calendar.DAY_OF_WEEK);
int maxDay = tempCal.getActualMaximum(Calendar.DAY_OF_MONTH);
int previousMonthCount = dayOfWeekOn1st - 1;
int index = 0;

if (previousMonthCount > 0) {
tempCal.set(Calendar.DAY_OF_MONTH, -1);
int previousMonthMax = tempCal.getActualMaximum(Calendar.DAY_OF_MONTH);

for (int i = previousMonthCount; i > 0; i--) {
int day = previousMonthMax - i + 1; 
if(i == previousMonthCount) {
_visibleStartDate = (Calendar)tempCal.clone();
_visibleStartDate.set(Calendar.DAY_OF_MONTH, day);
}
days[index] = day;
index++;
}
}

for (int i = 0; i < maxDay; i++) {
if(i == 0 && _visibleStartDate == null)
_visibleStartDate = (Calendar)tempCal.clone();
days[index] = (i + 1);
index++;
}

int nextMonthDay = 1;

for (int i = index; i < days.length; i++) {
if(i == index)
days[index] = nextMonthDay;
nextMonthDay++;
index++;
}
_visibleEndDate = (Calendar) _calendar.clone();
_visibleEndDate.add(Calendar.MONTH, 1);
_visibleEndDate.set(Calendar.DAY_OF_MONTH, days[41]);
return days;
}
public Calendar getSelectedDay() {
return (Calendar)_calendar.clone();
}
public Calendar getVisibleStartDate() {
return (Calendar) _visibleStartDate.clone();
}
public Calendar getVisibleEndDate() {
return (Calendar) _visibleEndDate.clone();
}

public void setOnDateChangedListener(OnDateChangedListener l) {
_onDateChangedListener = l;
}
public String toString(CharSequence format) {
return DateFormat.format(format, _calendar).toString();
}

private void invokeDateChangedListener() {
if (_onDateChangedListener != null)
_onDateChangedListener.onDateChanged(this);
}

private Calendar _calendar;
private String[] _shortDayNames;
private String[] _shortMonthNames;
private OnDateChangedListener _onDateChangedListener;
private Calendar _visibleStartDate;
private Calendar _visibleEndDate;
}

//-----------------------------------------------------------------

ic_calender_check.xml in drawable..

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/ic_calender_white_on" android:state_checked="true"/>

</selector>


//-----------------------------------------------------------

ic_calender_white_on.xml


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

 <item android:right="3dip" android:bottom="3dip">
        <bitmap
            android:src="@drawable/ic_cal_selecteddot"
            android:gravity="right|bottom"
            />
    </item>
 
</layer-list>  


//-------------------------------------------------

calender.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#076098"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/navigation"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:layout_marginLeft="8.5dip"
        android:layout_marginRight="9dip"
        android:background="@drawable/ic_caltop"
        android:orientation="horizontal"
        android:gravity="center" >

        <Button
            android:id="@+id/previous"
            android:scaleType="fitCenter"
            android:layout_width="20dip"
            android:layout_height="20dip"
            android:layout_marginLeft="12dip"
            android:background="@drawable/arrow_left_enabled"
            android:layout_gravity="center_vertical"
            android:visibility="visible" />

        <Button
            android:id="@+id/up"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@null"
            android:clickable="false"
            android:gravity="center"
            android:layout_weight="1"
            android:textSize="16sp"
            android:textStyle="bold" />

        <Button
            android:id="@+id/next"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="20dip"
            android:layout_height="20dip"
            android:layout_marginRight="12dip"
            android:background="@drawable/arrow_right_enabled"
            android:visibility="visible"
            android:layout_gravity="center_vertical" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/events"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="-2dip"
        android:background="@null"
        android:orientation="vertical"
        android:visibility="gone" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@null" />
    </LinearLayout>

    <TableLayout
        android:id="@+id/days"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2.35dip"
        android:layout_marginRight="3dip"
        android:background="@drawable/ic_procontent_mid"
        android:paddingLeft="3dip"
        android:stretchColumns="*"
        android:visibility="visible" >

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                 >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topright"
                android:layout_height="wrap_content"
                android:layout_marginRight="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_marginRight="4dip" 
                android:background="@drawable/ic_calender_topright"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_marginRight="4dip" 
                android:background="@drawable/ic_calender_topright"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topright"
                android:layout_marginRight="4dip" 
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_marginRight="4dip" 
                android:background="@drawable/ic_calender_topright"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>

        <TableRow>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_marginLeft="4dip" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:background="@drawable/ic_calender_topleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:background="@drawable/ic_calender_topleft"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_marginRight="4dip" 
                android:background="@drawable/ic_calender_topright"
                android:layout_height="wrap_content" >

                <CheckedTextView
                    style="@style/Day"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center" />
            </LinearLayout>
        </TableRow>
    </TableLayout>

    <TableLayout
        android:id="@+id/months"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_procontent_mid"
        android:stretchColumns="*"
        android:visibility="gone" >

        <TableRow>

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />
        </TableRow>

        <TableRow>

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />
        </TableRow>

        <TableRow>

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />

            <TextView style="@style/Month" />
        </TableRow>
    </TableLayout>

    <TableLayout
        android:id="@+id/years"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_procontent_mid"
        android:stretchColumns="*"
        android:visibility="gone" >

        <TableRow>

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />
        </TableRow>

        <TableRow>

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />
        </TableRow>

        <TableRow>

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />

            <TextView style="@style/Year" />
        </TableRow>
    </TableLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="3dip"
        android:layout_marginRight="3dip"
        android:background="@drawable/ic_procontent_bottom" >
    </LinearLayout>

</LinearLayout>


//----------------------------------------------------------------------


Style.xml



 <style name="Day" parent="@android:style/TextAppearance">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:paddingTop">0sp</item>
        <item name="android:paddingBottom">0sp</item>
        <item name="android:gravity">center</item>
        <item name="android:textColor">#076098</item>
    </style>

    <style name="Month" parent="@android:style/TextAppearance">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:padding">10sp</item>
        <item name="android:gravity">center</item>
        <item name="android:textColor">#cccccc</item>
    </style>

    <style name="Year" parent="@android:style/TextAppearance">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:padding">10sp</item>
        <item name="android:gravity">center</item>
        <item name="android:textColor">#cccccc</item>
    </style>


//--------------------------------------------------------


ic_calender_gray_on.xml


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:left="0dip">
        <shape android:shape="rectangle" >
            <solid android:color="#d8e0e5" />
        </shape>
    </item>
     <item android:right="3dip" android:bottom="3dip">
        <bitmap
            android:src="@drawable/ic_cal_selecteddot"
            android:gravity="right|bottom"
            />
    </item>
 
</layer-list>  
//----------------------------------------------------------------


call in class-----------------------


private CalendarView calenderView;
private CalendarWrapper wrapper;


final Dialog d = new Dialog(CreateAccount.this);

d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.calender_main);

calenderView = (CalendarView) d.findViewById(R.id.calendar_view);
wrapper = new CalendarWrapper();
d.setCancelable(true);

calenderView
.setOnMonthChangedListener(new OnMonthChangedListener() {
public void onMonthChanged(CalendarView view) {
System.out.println("reclickkkk");
// markDays();
}
});

calenderView
.setOnSelectedDayChangedListener(new OnSelectedDayChangedListener() {
public void onSelectedDayChanged(CalendarView view) {

Calendar c = view.getSelectedDay();
int dates = c.get(Calendar.DATE);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int cMonth = month + 1;
String age = getAge(year, cMonth, dates);

String a = String.valueOf(cMonth)
+ String.valueOf(dates);
int finaldate = Integer.parseInt(a);
etBirthday.setText(String.valueOf(dates) + " "
+ view._up.getText().toString());
etAge.setText(age);

etAstroSign.setText(getZodiacSign(finaldate));
d.dismiss();

 

Popular Posts

About Me

Only For Sharing Android Related Things...

Facebook Fan Page