I tried to display date picker using xml code. But it did not display anything. Can I display DatePicker only through java code?
public class datePickerExample extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.date_picker_example);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lay_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Date : " >
</TextView>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:endYear="2100"
android:startYear="1900" >
</DatePicker>
</LinearLayout>
Thank you...
Add this attribute:
android:orientation="vertical"
in your LinearLayout element and the date-picker will appear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With