Friday 10 February 2012

DatePickerDialog & TimePickerDialog in Android

DatePickerDialog is not a View, that you can’t define it in the xml layout file.
Instead you declare it from code with the following two constructors:




DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth);
DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth);


You can use it like this:
public void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=(Button)findViewById(R.id.btn);

final OnDateSetListener odsl=new OnDateSetListener()
        {

   public void onDateSet(DatePicker arg0, int year, int month, int dayOfMonth) {
    // TODO Auto-generated method stub
    TextView txt=(TextView)findViewById(R.id.txt);
    txt.setText("The date is "+dayOfMonth+"/"+month+"/"+year);
   }
         
        };

btn.setOnClickListener(new OnClickListener()
        {

   public void onClick(View arg0) {
    // TODO Auto-generated method stub
   
    
    Calendar cal=Calendar.getInstance();
    DatePickerDialog datePickDiag=new DatePickerDialog(DateTimeControls.this,odsl,cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH));
    datePickDiag.show();
   }
         
        }
        
        );

}


To take an action when the date is set you define an OnDateSelectedListner and implement the onDateSet method

TimePickerDialog

DatePickerDialog is similar to DatePickerDialog but used for setting time.

The constructors for TimePickerDialog are:

TimePickerDialog(Context context, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView);

TimePickerDialog(Context context, int theme, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView);
Code :  
public void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=(Button)findViewById(R.id.btn);
}

final OnTimeSetListener otsl=new OnTimeSetListener()
        {

   public void onTimeSet(TimePicker arg0, int hourOfDay, int minute) {
    // TODO Auto-generated method stub
    TextView txt=(TextView)findViewById(R.id.txt);
    txt.setText("The time is "+hourOfDay+":"+minute);
   }
        };

btn.setOnClickListener(new OnClickListener()
        {

   public void onClick(View arg0) {
    // TODO Auto-generated method stub
   
    
    Calendar cal=Calendar.getInstance();
    TimePickerDialog timePickDiag=new TimePickerDialog(DateTimeControls.this,otsl,cal.get(Calendar.HOUR_OF_DAY),cal.get(Calendar.MINUTE),true);
    timePickDiag.show();
   }
         
        }
        
        );

Google TV


Google TV is built on Android and Chrome platforms that provide a scalable way to bring your apps to TV.


https://developers.google.com/tv/

Device Policy Administration for Android


The Device Administration API provides device administration features at the system level. These APIs allow you to create security-aware applications that are useful in enterprise settings, in which IT professionals require rich control over employee devices.
 
 
 

Android Asset Studio : Android Icon Generating Tool


Following the Android User Interface Guidelines is important to make an app feel like it fits in naturally with the rest of the OS. A great tool to help with this is the Android Asset Studio.


Asset Studio takes basic vector shapes, clip art, and so on and makes icon resources that follow the guidelines. It supports Launcher, Menu, Action Bar, Tab and Notification icons as well as placing screenshots into phone frames.


http://code.google.com/p/android-ui-utils/

Try this link  http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html  in Google Chrome or Updated Firefox Beta versions.