Posts

Showing posts from August, 2017

Toast in Android

Image
Android Toast is used to show sort message. Toast message takes only that amount of space that is required to show message, and during that time activity is visible and user can interact with it. Toasts automatically disappear after a timeout.                                                        Toast Usage : We can use Toast to show sort message as follows: Toast . makeText ( getApplicationContext(), "Your Message" , Toast . LENGTH_LONG ).show(); We need to pass 3 arguments in Toast.makeText(Context context,String message,int length) function as follows: Context: First argument is Context object String: Message which you want to display in Toast. int: third parameter  is duration. It can have values Toast. LENGTH_SHORT or Toast. LENGTH_LONG Set Position of Toast :    We can change the position of Toast with the setGravity(int, int, int) method of Toast object. This accepts three parameters: a Gravity constant, an x-position offset, a

Disable/Hide Year from DatePickerDialog in android

Image
DatePickerDialog in Android is the most essential part . We can easily customize DatePickerDialog in Android . Here is the example to disable/hide Year from DatePickerDialog in Android .   The given bellow code will work from API 5.0+ DatePickerDialog Constructor :  1. Context  : Require Application context  2. new DatePickerDialog.OnDateSetListener(){         onDataSet()  // this method execute when user select date and press ok button           {            a. Year  // selected year            b. Month // selected month , it's return previous month. Suppose you select March then it return 2 insted of 3 .            c. Day  // selected date       }     }      3. Year // popup visible year  4. Month  // popup visible month  5. Day   // popup visible date Step 1:   Create Project            a) Open Android Studio           b) Go to File >New> New Project  > Project Name  > Next > Next > Next > Finish  Step

Disable/Hide Month from DatePickerDialog in android

Image
DatePickerDialog in Android is the most essential part . We can easily customize DatePickerDialog in Android . Here is the example to disable/hide Month from DatePickerDialog in Android .   The given bellow code will work from API 5.0+ DatePickerDialog Constructor :  1. Context  : Require Application context  2. new DatePickerDialog.OnDateSetListener(){         onDataSet()  // this method execute when user select date and press ok button           {            a. Year  // selected year            b. Month // selected month , it's return previous month. Suppose you select March then it return 2 insted of 3 .            c. Day  // selected date       }     }      3. Year // popup visible year  4. Month  // popup visible month  5. Day   // popup visible date Step 1:   Create Project            a) Open Android Studio           b) Go to File >New> New Project  > Project Name  > Next > Next > Next > Finish  Ste

Disable/hide Date from DatePickerDialog in Android

Image
DatePickerDialog in Android is the most essential part . We can easily customize DatePickerDialog in Android . Here is the example to disable/hide Date from DatePickerDialog in Android .   The given bellow code will work from API 5.0+ DatePickerDialog Constructor :  1. Context  : Require Application context  2. new DatePickerDialog.OnDateSetListener(){         onDataSet()  // this method execute when user select date and press ok button           {            a. Year  // selected year            b. Month // selected month , it's return previous month. Suppose you select March then it return 2 insted of 3 .            c. Day  // selected date       }     }      3. Year // popup visible year  4. Month  // popup visible month  5. Day   // popup visible date Step 1:   Create Project            a) Open Android Studio           b) Go to File >New> New Project  > Project Name  > Next > Next > Next > Finish  S