Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Unable to open dialog window / trigger touch event
    text
    copied!<p>I have a tab fragment on which I am loading a layout. This layout contains a button with an event handler but seems the event is never triggered.</p> <pre><code>public class SettingsFragmentTab extends Fragment { private Button mPickTime; private int mHour; private int mMinute; static final int TIME_DIALOG_ID = 0; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout frame = (FrameLayout)inflater.inflate(R.layout.settings_list_content, container, false); mPickTime = (Button) frame.findViewById(R.id.pickTime); // add a click listener to the button mPickTime.setOnClickListener(new OnClickListener() { public void onClick(View v) { getActivity().showDialog(TIME_DIALOG_ID); } }); return frame; } // the callback received when the user "sets" the time in the dialog private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(android.widget.TimePicker view, int hourOfDay, int minute) { mHour = hourOfDay; mMinute = minute; } }; </code></pre> <p><strong>Layout</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;RelativeLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="right" &gt; &lt;TextView android:id="@+id/schedule" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical" android:text="Schedule" android:textColor="#FFFFFF" android:textSize="20dp" /&gt; &lt;Button android:id="@+id/pickTime" android:layout_width="50dp" android:layout_height="50dp" android:layout_toRightOf="@id/schedule" android:background="@drawable/addtime" android:gravity="right" /&gt; &lt;ListView android:id="@+id/listSettings" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_above="@id/app_name_tv" android:layout_below="@id/pickTime" android:divider="@android:color/transparent" android:dividerHeight="15.0sp" /&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_width="164dp" android:layout_height="67dp" android:layout_gravity="right" android:gravity="right" &gt; &lt;TextView android:id="@+id/timezone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="15dp" android:layout_alignWithParentIfMissing="true" android:layout_alignParentRight="true" android:text="Select Your Timezone: " /&gt; &lt;Spinner android:id="@+id/spinner1" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_alignLeft="@+id/timezone" android:layout_alignParentRight="true" android:layout_below="@id/timezone" android:textAppearance="@drawable/spinner_style" /&gt; &lt;/RelativeLayout&gt; &lt;/FrameLayout&gt; </code></pre> <p>I have been looking at the code over and over again, but cannot seem to find the issue why the button "mPickTime" 's event not getting triggered.</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