Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I reach the datepicker in a popup from my main activity?
    text
    copied!<p>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?</p> <p>I just have to be able to get the value of the datepicker when the popup is closed again.</p> <p>This is my method making and closing the popup:</p> <pre><code>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); } } </code></pre> <p>My xml file: (dateselect.xml)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;DatePicker android:id="@+id/datePicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Thankx</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload