I can't find how to reach the datepicker in a popup from the main Activity. When I call findIdByView() to get the datepicker, the program looks in the layout of main. But the datepicker is defined in the popuplayout. How do I get there?
I just have to be able to get the value of the datepicker when the popup is closed again.
This is my method making and closing the popup:
public void onSelectDayClick(View view)
{
if(popup.isShowing())
{
//DatePicker datepicker = (DatePicker) this.findViewById(R.id.datePicker); (doesn't work)
int year = datepicker.getYear();
int month = datepicker.getMonth();
int day = datepicker.getDayOfMonth();
;displayday = new DateTime(year, month, day, 12, 00);
popup.dismiss();
;newDay();
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
popup = new PopupWindow(inflater.inflate(R.layout.dateselect, null, false),LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
}
else
{
popup.showAtLocation(this.findViewById(R.id.scrollView), Gravity.BOTTOM, 0, 150);
}
}
My xml file: (dateselect.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<DatePicker
android:id="@+id/datePicker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
Thankx