title: Add a switch case inside case DialogInterface.BUTTON_POSITIVE
body: <p>In my android app, i have an actvity with different number inside a linear layout per number. Each linear layout has an onClick method  that call a method in the activity to show a dialog before call the number,  and if button YES is choosen, an intent action_call starts.</p>
  
  <p>Here is my xml file:</p>
  
  <pre><code>...
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:onClick="onClick"
      android:id="@+id/ln_u"&gt;
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/ps_u"
          android:src="@mipmap/ic_call"
          android:background="@android:color/transparent"
          android:layout_marginLeft="12dp"
          /&gt;
  
      &lt;TextView
          android:id="@+id/nu"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_alignParentRight="true"
          android:text="123456"
          android:textSize="17sp"
          android:layout_marginTop="5dp"
          android:layout_marginLeft="16dp" /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:onClick="onClick"
      android:id="@+id/ln_r"&gt;
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/ps_r"
          android:src="@mipmap/ic_call"
          android:background="@android:color/transparent"
          android:layout_marginLeft="12dp"
          /&gt;
  
      &lt;TextView
          android:id="@+id/nu"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_alignParentRight="true"
          android:text="123456"
          android:textSize="17sp"
          android:layout_marginTop="5dp"
          android:layout_marginLeft="16dp" /&gt;
  
  &lt;/LinearLayout&gt;
  
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:onClick="onClick"
      android:id="@+id/ln_t"&gt;
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/ps_t"
          android:src="@mipmap/ic_call"
          android:background="@android:color/transparent"
          android:layout_marginLeft="12dp"
         /&gt;
  
      &lt;TextView
          android:id="@+id/nu"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_alignParentRight="true"
          android:text="123456"
          android:textSize="17sp"
          android:layout_marginTop="5dp"
          android:layout_marginLeft="16dp" /&gt;
  
  &lt;/LinearLayout&gt;
  ...
  </code></pre>
  
  <p>In the activity i added the method "onClick" with the Dialog for "yes/no" calling, and for one number it works properly.</p>
  
  <p>That is the part of the main for the dialog and the onClick method:</p>
  
  <pre><code>@Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          AlertDialog ad = new AlertDialog.Builder(this)
                  .setMessage("Call the number?   ")
                  //.setIcon(R.mipmap.ic_alert)
                  .setTitle("Call")
                  .setPositiveButton("Yes", this)
                  .setNegativeButton("No", this)
                  .setCancelable(false)
                  .create();
  
          ad.show();
      }
  
      @Override
      public void onClick(DialogInterface dialog, int which) {
          // TODO Auto-generated method stub
          switch(which){
              case DialogInterface.BUTTON_POSITIVE: // yes
                          String number = "123456";
                          Uri call = Uri.parse("tel:" + number);
                          Intent intent = new Intent(Intent.ACTION_CALL, call);
                          startActivity(intent);
  
                          break;
              case DialogInterface.BUTTON_NEGATIVE: // no
                  break;
              default:
                  // nothing
                  break;
          }
      }
  </code></pre>
  
  <p>What i want to achieve is the possibility to add another Switch/case method into the "case DialogInterface.BUTTON_POSITIVE:" that take the id of the different linear layout, and for each id, call the relative number with the intent call_action.</p>
  
  <p>Hope someone can help me.
  Thanks in advance</p>
  
  <p>Brus</p>