title: how to send string array from custom adpter to main activity
body: <p>I am a new android Developer and i want to send String Array from Custom ADapter to main activity class but my code is not working and I am Using CustomAdapter class please can any help me</p>
  
  <p>My ContactList class is following.....</p>
  
  <pre><code>public class ContactList extends Activity {
      ListView lvContacts;
      List&lt;String&gt; listname;
      List&lt;String&gt; listnumber;
      SimpleCursorAdapter adapter;
      ArrayList&lt;PhoneList&gt; arr;
      ArrayList&lt;PhoneList&gt; arrnumber;
      Button smsbtn;
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          smsbtn = (Button) findViewById(R.id.sms);
          String[] projection = new String[] {
                  ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                  ContactsContract.CommonDataKinds.Phone.NUMBER, };
          Cursor c1 = getContentResolver().query(
                  ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
                  null, null, null);
              listname = new ArrayList&lt;String&gt;();
          listnumber = new ArrayList&lt;String&gt;();
          while (c1.moveToNext()) {
              String name = c1
                      .getString(c1
                              .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
              String number = c1
                      .getString(c1
                              .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
              listname.add(name);
              listnumber.add(number);
          }
          c1.close();
          Object[] obj = listname.toArray();
          Object[] objnumber = listnumber.toArray();
          arr = new ArrayList&lt;PhoneList&gt;();
          String[] da = new String[obj.length];
          String[] danumber = new String[objnumber.length];
          for (int i = 0; i &lt; obj.length; i++) {
              danumber[i] = (String) objnumber[i];
              da[i] = (String) obj[i];
              arr.add(new PhoneList(da[i], danumber[i], i));
          }
          ListView listView = (ListView) findViewById(R.id.lvContacts);
          CustomAdapter adpttt = new CustomAdapter(ContactList.this,
                  R.layout.contacts_list_item, arr);
          listView.setAdapter(adpttt);
          smsbtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  Intent intent = getIntent();
                  String[] myStrings = intent.getStringArrayExtra("numberarray");
                  for (int i = 0; i &lt; myStrings.length; i++) {
                      Toast.makeText(getApplicationContext(), myStrings[i],
                              Toast.LENGTH_LONG).show();
                  }
  
              }
          });
      }
  
  }
  </code></pre>
  
  <p>My Custom Adapter Class is Following....</p>
  
  <pre><code>public class CustomAdapter extends ArrayAdapter&lt;PhoneList&gt; {
      int inflatr;
      Context ctxt;
      boolean bulkflag = false;
      static int k=0;
      ArrayList&lt;PhoneList&gt; data=new ArrayList&lt;PhoneList&gt;();
      private static final String[] arr1=new String[256];
      private static String[] arr=new String[256];
          public CustomAdapter(Context context, int resource, ArrayList&lt;PhoneList&gt; arr) {
  
          super(context, resource, arr);
          this.inflatr = resource;
          this.ctxt = context;
          this.data= arr;
      }
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
           UserHolder holder = null;
           View row = convertView;
          if(convertView==null)
          {
               LayoutInflater inflater = ((Activity) ctxt).getLayoutInflater();
               row = inflater.inflate(inflatr, parent, false);
               holder = new UserHolder();
               holder.textName=(TextView)row.findViewById(R.id.lblName);
               holder.stnumber=(TextView)row.findViewById(R.id.mobilenum);
               holder.checked=(CheckBox)row.findViewById(R.id.check);
  
  //           holder.btnEdit = (ImageButton) row.findViewById(R.id.atomPay_removePay);
               row.setTag(holder);
          }
          else
          {
               holder = (UserHolder) row.getTag();            
          }
           final PhoneList dta=data.get(position);
           holder.checked.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
  
                   int position = (Integer) v.getTag();
                   data.get(position).setselect(!data.get(position).getSelect());
                   notifyDataSetChanged();
                   arr=dta.getnumberr();
                   arr1[k]=arr[position];
              }
          });
  
           holder.checked.setChecked(dta.getSelect());
  
           holder.checked.setTag(position);
          for(int i=0; i&lt;=data.size(); i++)
          {
              holder.textName.setText(dta.getName());
          }
          for(int j=0; j&lt;=data.size(); j++)
          {
              holder.stnumber.setText(dta.getNumber());
          }
  
  //      holder.btnEdit.setOnClickListener(new OnClickListener() {
  //          
  //          @Override
  //          public void onClick(View v) {
  //              Toast.makeText(ctxt, "Humayoon    Siddiqueeeeeeeeeeeeeeeeeee"+dta.getName(), Toast.LENGTH_SHORT).show();
  //              Intent moreIntent=new Intent(getContext(),ContactList.class);
  //              String tName=dta.getName();
  //              moreIntent.putExtra("Template",tName);
  //              v.getContext().startActivity(moreIntent);
  //               // ctxt.startActivity(ctxt,ContactList.class);
  //          }
  //      });
          Intent ii=new Intent(getContext(),ContactList.class);
          ii.putExtra("numberarray", arr1);
          return row;
      }
      @Override
      public int getCount() {
  //      // TODO Auto-generated method stub
          return data.size();
      }
  
      static class UserHolder {
          TextView textName;
          TextView textAddress;
          TextView textLocation;
          ImageButton btnEdit;
          Button btnDelete;
          TextView stnumber;
          CheckBox checked;
          }
  
  
  }
  </code></pre>
  
  <p>My xml Layout is following....</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:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@layout/bg_player_header"
      &gt;
      &lt;ListView
          android:id="@+id/lvContacts"
          android:layout_width="match_parent"
          android:layout_height="422dp"
          android:divider="#FFEEEE" &gt;
  &lt;/ListView&gt;
  
      &lt;Button
          android:id="@+id/sms"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="28dip"
          android:layout_marginLeft="109dip"
          android:text="Send Sms"
          android:onClick="btnclicked"
           /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>