title: RadioGroup listener dont work
body: <p>I have a <code>Fragment</code> that displays a <code>Dialog</code>.
  Inside that <code>Dialog</code> there is a <code>RadioGroup</code>.
  I tried to create a listener to this <code>RadioGroup</code>, but i didn't successed.</p>
  
  <p><code>Fragment</code> --> <code>Dialog</code> --> <code>RadioGroup</code></p>
  
  <p>I tried four ways:</p>
  
  <ol>
  <li><code>OnCheckedChangeListener</code> on <code>RadioGroup</code>. </li>
  <li><code>OnClickListener</code> on <code>RadioGroup</code>.</li>
  <li><code>OnCheckedChangeListener</code> on <code>RadioButton</code>.</li>
  <li><code>OnClickListener</code> on <code>RadioButton</code></li>
  </ol>
  
  <p>No one worked.</p>
  
  <p>Here is my code:</p>
  
  <p>The <code>Dialog</code> - layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  
  
      &lt;RadioGroup
          android:id="@+id/bS_rg"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:orientation="vertical"&gt;
  
          &lt;RadioButton
              android:id="@+id/r_id"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:text="ID"
              android:textSize="24sp" /&gt;
  
          &lt;RadioButton
              android:id="@+id/r_title"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:text="Title"
              android:textSize="24sp" /&gt;
  
          &lt;RadioButton
              android:id="@+id/r_genre"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:text="Genre"
              android:textSize="24sp" /&gt;
  
          &lt;RadioButton
              android:id="@+id/r_author"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:text="Author"
              android:textSize="24sp" /&gt;
  
      &lt;/RadioGroup&gt;
  
      &lt;AutoCompleteTextView
          android:id="@+id/c_bSearch"
          android:layout_width="278dp"
          android:layout_height="72dp"
          android:singleLine="true"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The <code>Fragment</code> - layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;de.codecrafters.tableview.TableView
          android:id="@+id/tableView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And the <code>Fragment</code> - code: (I marked where is the problem, the other code is not important)</p>
  
  <pre><code>package com.example.adiel.library_app_30;
  
  import .....;
  
  public class ShowAllBooks extends Fragment {
      View v;
      TableLayout table;
      TableRow row;
      String[] spaceProbeHeaders = {"ID", "Title"};
      String[][] spaceProbes;
      AutoCompleteTextView c_search;
  
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
          v = inflater.inflate(R.layout.show_all_books, container, false);
          setHasOptionsMenu(true);
  
          /*
          ------The problem is here----
          */
          LayoutInflater li = LayoutInflater.from(v.getContext());
          View promptsView = li.inflate(R.layout.b_search_dialog, null);
          c_search = (AutoCompleteTextView) promptsView.findViewById(R.id.c_bSearch);
          RadioGroup rg = (RadioGroup) promptsView.findViewById(R.id.bS_rg);
          rg.check(R.id.r_id);
  
          rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(RadioGroup group, int checkedId)
              {
                  Log.d("Log", "Clicked");
              }
          });
  
          rg.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Log.d("Log", "Clicked");
              }
          });
          RadioButton r_id = (RadioButton) promptsView.findViewById(R.id.r_id);
          r_id.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  Log.d("Log", "Clicked");
              }
          });
          r_id.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Log.d("Log", "Clicked");
              }
          });
          /*
          ------Until here----
          */
  
  
          final TableView&lt;String[]&gt; tb = (TableView&lt;String[]&gt;) v.findViewById(R.id.tableView);
          tb.setColumnCount(2);
          tb.setHeaderBackgroundColor(Color.parseColor("#2ecc71"));
  
          Ask a = new Ask("books", "getAllCopiesOfBooks", null);
          Client client = (Client) new Client(a, a.getIp(), v.getContext(), new Client.ClientReply() {
              @Override
              public void processFinish(Object output) {
                  if (output != null) {
                      ArrayList&lt;CopyId&gt; data = (ArrayList&lt;CopyId&gt;) output;
                      spaceProbes = new String[data.size()][2];
                      for (int i = 0; i &lt; data.size(); i++) {
                          CopyId c = data.get(i);
                          spaceProbes[i][0] = String.valueOf(c.getId());
                          spaceProbes[i][1] = c.getTitle();
                      }
                      tb.setHeaderAdapter(new SimpleTableHeaderAdapter(v.getContext(), spaceProbeHeaders));
                      tb.setDataAdapter(new SimpleTableDataAdapter(v.getContext(), spaceProbes));
                  }
              }
          }).execute();
  
          tb.addDataClickListener(new TableDataClickListener() {
              @Override
              public void onDataClicked(int rowIndex, Object clickedData) {
                  Toast.makeText(v.getContext(), ((String[]) clickedData)[0], Toast.LENGTH_SHORT).show();
                  Intent i = new Intent(v.getContext(), ShowBook.class);
                  i.putExtra("id", ((String[]) clickedData)[0]);
                  startActivity(i);
              }
          });
  
          return v;
      }
  
      @Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
          inflater.inflate(R.menu.showallbooks_menu, menu);
          super.onCreateOptionsMenu(menu, inflater);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()){
              case R.id.action_add:
  
                  return true;
              case R.id.action_search:
                  search_func();
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public void search_func(){
          final Dialog dialog = new Dialog(v.getContext());
          dialog.setContentView(R.layout.b_search_dialog);
          dialog.setTitle("Search");
          dialog.show();
  
  
  
  
          //RadioButton r_id = (RadioButton) promptsView.findViewById(R.id.r_id);
          /*RadioButton r_title = (RadioButton) v.findViewById(R.id.r_title);
          RadioButton r_genre = (RadioButton) v.findViewById(R.id.r_genre);
          RadioButton r_author = (RadioButton) v.findViewById(R.id.r_author);*/
  
  
  
      }
  }
  </code></pre>