Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android listview仅显示第一条记录_Android - Fatal编程技术网

Android listview仅显示第一条记录

Android listview仅显示第一条记录,android,Android,我制作了一个应用程序,其中我从sqllite数据库中检索数据,但它只显示数据库中的第一条记录,其余的不显示。我只想用rowid从数据库中检索名称,但它也在向我显示消息。 Campaign_Details.java package com.example.smscampaign; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.concurrent.

我制作了一个应用程序,其中我从sqllite数据库中检索数据,但它只显示数据库中的第一条记录,其余的不显示。我只想用rowid从数据库中检索名称,但它也在向我显示消息。 Campaign_Details.java

    package com.example.smscampaign;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Semaphore;

import com.example.second.Scale;




import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class Campaign_Details extends Activity implements OnClickListener {
     Cursor c;
     private DataBaseHelp mdb;
        private ListView lvMessage;
        private ArrayList<Bean> alSentMessage;
        private Demo adapter;
        public String ADD_TO_NAME="toname";
 ListView listview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_demostration);
        TextView txt1= (TextView) findViewById(R.id.data);
         listview = (ListView) findViewById(R.id.listview);
         PackageInfo pInfo = null;
         try 
         {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
         } 
         catch (NameNotFoundException e) 
         {
            e.printStackTrace();
         }
        txt1.setText(pInfo.versionName);

        TextView txt= (TextView) findViewById(R.id.textnum1);
  /*      mdb=new DataBaseHelp(this);
        alSentMessage=new ArrayList<Bean>();
        lvMessage=(ListView)findViewById(R.id.listview);
        c=mdb.fetchAllContacts();
        c.moveToFirst();
        Log.d("cursor",""+c.getCount());
        while(c.moveToNext()){
          Bean mb=new Bean();
          Log.e("ColumnIndex",""+c.getColumnIndex(DataBaseHelp.KEY_NAME));
          mb.setToName((c.getString(c.getColumnIndex(DataBaseHelp.KEY_NAME))));
          alSentMessage.add(mb);
        }
        adapter=new Demo(Campaign_Details.this,alSentMessage);
        lvMessage.setAdapter(adapter);*/
      //  String [] values1= data.split("\n");
       // int t = values1.length;
       // txt.setText(Integer.toString(t));

       // String[] values = new String[] { data };
        DataBaseHelp info= new DataBaseHelp(this);
        info.open();
        //ArrayList<String> list1 = new ArrayList<String>();
        //list1= info.getData();
        //String[] values= list1.;
        ArrayList<String> arr = info.getData();
                final ArrayList<String> list = new ArrayList<String>();
                for (int i = 0; i <  arr.size(); i++) {
                    list.add(arr.get(i));
                }
                adapter = new Demo(this, list);
              //  Demo.setNotifyOnChange(true);


                listview.setAdapter(adapter);


       listview.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
         Intent i= new Intent("com.example.second.SMSSEND");
        String mName= SmsSend.ed1.getText().toString();
       String mScale=SmsSend.ed2.getText().toString();
       String mContatcs= SmsSend.conct.toString() ;
      String st=   information.getText().toString();
        long lt= Long.parseLong(st);
        DataBaseHelp e= new DataBaseHelp(this);
        e.open();
        e.updateEntry(lt,mName,mScale,mContatcs);

        e.close();  
         startActivity(i);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // TODO Auto-generated method stub
        getMenuInflater().inflate(R.menu.main2, menu);
        return true;

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub

        switch (item.getItemId()) {
        case R.id.nextPage:
            Intent i= new Intent(Campaign_Details.this,SmsSend.class);
            startActivity(i);
            break;

        }
        return true;
    }




}  
package com.example.smscampaign;
导入java.util.ArrayList;
导入java.util.HashMap;
导入java.util.List;
导入java.util.concurrent.Semaphore;
导入com.example.second.Scale;
导入android.annotation.SuppressLint;
导入android.app.Activity;
导入android.content.Context;
导入android.content.Intent;
导入android.content.pm.PackageInfo;
导入android.content.pm.PackageManager.NameNotFoundException;
导入android.database.Cursor;
导入android.database.sqlite.SQLiteDatabase;
导入android.os.Build;
导入android.os.Bundle;
导入android.util.Log;
导入android.view.Menu;
导入android.view.MenuItem;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.AdapterView;
导入android.widget.ArrayAdapter;
导入android.widget.ListView;
导入android.widget.TextView;
导入android.widget.Toast;
公共类活动\u详细信息扩展活动实现OnClickListener{
光标c;
私有数据库帮助mdb;
私有ListView消息;
私有ArrayList-alSentMessage;
专用演示适配器;
公共字符串ADD_TO_NAME=“toname”;
列表视图列表视图;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u list\u demonstration);
TextView txt1=(TextView)findViewById(R.id.data);
listview=(listview)findViewById(R.id.listview);
PackageInfo pInfo=null;
尝试
{
pInfo=getPackageManager().getPackageInfo(getPackageName(),0);
} 
catch(nameNotFounde异常)
{
e、 printStackTrace();
}
txt1.setText(pInfo.versionName);
TextView txt=(TextView)findViewById(R.id.textnum1);
/*mdb=新数据库帮助(此);
alSentMessage=newarraylist();
lvMessage=(ListView)findViewById(R.id.ListView);
c=mdb.fetchAllContacts();
c、 moveToFirst();
Log.d(“游标”,“c.getCount());
while(c.moveToNext()){
Bean mb=newbean();
Log.e(“ColumnIndex”,“c.getColumnIndex(DataBaseHelp.KEY_NAME));
setToName((c.getString(c.getColumnIndex(DataBaseHelp.KEY_NAME)));
添加(mb);
}
adapter=新演示(活动详细信息,此为alSentMessage);
lvMessage.setAdapter(适配器)*/
//字符串[]值1=data.split(“\n”);
//int t=值1.1长度;
//setText(Integer.toString(t));
//字符串[]值=新字符串[]{data};
DataBaseHelp info=新的DataBaseHelp(此);
info.open();
//ArrayList list1=新的ArrayList();
//list1=info.getData();
//字符串[]值=列表1。;
ArrayList arr=info.getData();
最终ArrayList=新ArrayList();
对于(int i=0;i
活动列表演示.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:stretchColumns="3" >

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textcolour"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:background="@drawable/green_circle" />

                <TextView
                    android:id="@+id/text1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:paddingLeft="10dp"
                    android:text="Active Campaign"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="#4AE56B" />

                <TextView
                    android:id="@+id/textnum1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginRight="130dp"
                    android:background="@drawable/green_badge"
                    android:gravity="center"
                    android:text=" 0 "
                    android:textColor="@color/white" />
            </TableRow>
        </TableLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="240dp"
            android:orientation="vertical" >
     <TextView
                android:id="@+id/data"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                >
            </TextView>
            <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <ListView
                    android:id="@+id/listview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black" />
            </ScrollView>
        </LinearLayout>

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:stretchColumns="3" >

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textcolour"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:background="@drawable/grey_circle" />

                <TextView
                    android:id="@+id/text2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="10dp"
                    android:text="Closed Campaign"
                    android:textAppearance="?android:attr/textAppearanceLarge" />

                <TextView
                    android:id="@+id/textnum2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginRight="130dp"
                    android:background="@drawable/grey_badge"
                    android:gravity="center"
                    android:text=" 0 "
                    android:textColor="@color/white" />
            </TableRow>
        </TableLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="140dp"
            android:orientation="vertical" >

            <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <ListView
                    android:id="@+id/listview1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black" />
            </ScrollView>
        </LinearLayout>

    </LinearLayout>

Demo.java

 package com.example.smscampaign;

import java.util.ArrayList;


import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Demo extends ArrayAdapter<String>{

private ArrayList<String> values=null;
private final Context context;
public Demo(Context context, ArrayList<String> values) {
    super(context,R.layout.list, values);
    this.context=context;
    this.values= values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowview= inflater.inflate(R.layout.list, parent,false);
    TextView txt=(TextView) rowview.findViewById (R.id.text1);
    //ImageView img=(ImageView) rowview.findViewById (R.id.icon);
    txt.setText(values.get(position));
    //changing icon

    return rowview;
}
}



list.xml



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


       <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

    </LinearLayout>
package com.example.smscampaign;
导入java.util.ArrayList;
导入android.content.Context;
导入android.util.Log;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.ArrayAdapter;
导入android.widget.BaseAdapter;
导入android.widget.ImageView;
导入android.widget.TextView;
公共类演示扩展ArrayAdapter{
私有ArrayList值=null;
私人最终语境;
公共演示(上下文、ArrayList值){
super(上下文、R.layout.list、值);
this.context=context;
这个。值=值;
}
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
LayoutFlater充气器=(LayoutFlater)context.getSystemService(context.LAYOUT\u充气器\u服务);
视图行视图=充气机充气(R.layout.list,父级,false);
TextView txt=(TextView)rowview.findViewById(R.id.text1);
//ImageView img=(ImageView)rowview.findViewById(R.id.icon);
 package com.example.smscampaign;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Comment;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;



public class DataBaseHelp{

    public static final String KEY_ROWID="_id";
    public static final String KEY_NAME="person_name";
    public static final String KEY_SCALE="scale_person";
    public static final String KEY_CONTACTS="Contacts_person";

    private static final String DATABASE_NAME="Himani";
     static final String DATABASE_TABLE="peopleTable";
    private static final int DATABASE_VERSION=1;

    private DbHelper ourHepler;
    private final Context ourContext;
     SQLiteDatabase ourDatabase;
    public class DbHelper extends SQLiteOpenHelper{

        public DbHelper(Context context) {
            super(context,DATABASE_NAME,null,DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL( "CREATE TABLE " + DATABASE_TABLE + " (" +
                    KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT,  " +
                    KEY_NAME + " TEXT NOT NULL, " +
                    KEY_SCALE + " TEXT NOT NULL ,"  + KEY_CONTACTS + ")"
                    );
            }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
            onCreate(db);
        }

    }

    public DataBaseHelp(Context c){
        ourContext=c;
    }


    public DataBaseHelp open() throws SQLException{
        ourHepler = new DbHelper(ourContext);
        ourDatabase=  ourHepler.getWritableDatabase();
        return this;
    }
    public void close()
    {
        ourHepler.close();
    }


    public long entryCreate(String name, String scale , String contacts) {
        // TODO Auto-generated method stub

        ContentValues cv=new ContentValues();
        cv.put(KEY_NAME, name);
        cv.put(KEY_SCALE, scale);
        cv.put(KEY_CONTACTS, contacts);
        return ourDatabase.insert(DATABASE_TABLE, null, cv); 

    }


    public ArrayList<String> getData() {

        String[] col= new String[]{KEY_ROWID,KEY_NAME,KEY_SCALE, KEY_CONTACTS};
        Cursor c=  ourDatabase.query(DATABASE_TABLE, col, null, null, null, null, null);
        String run="";
        int iRow=c.getColumnIndex(KEY_ROWID);
        int iName=c.getColumnIndex(KEY_NAME);
        int iScale=c.getColumnIndex(KEY_SCALE);
        int iMessage=c.getColumnIndex(KEY_CONTACTS);
        ArrayList<String> newList= new ArrayList<String>();
        for(c.moveToFirst();!c.isAfterLast();c.moveToNext()){
         newList.add(c.getString(iRow)+ " " + c.getString(iName) + " " + c.getString(iScale) + " " + c.getString(iName));
        }

        return newList;
    }

    public Cursor fetchAllContacts()

    { 
        ourDatabase=ourHepler.getReadableDatabase();

    String selectQuery = "SELECT *  FROM " + DATABASE_TABLE;

    return ourDatabase.rawQuery(selectQuery, null);
    }



    public String getScale(long l) {
        // TODO Auto-generated method stub
        String[] col= new String[]{KEY_ROWID,KEY_NAME,KEY_SCALE , KEY_CONTACTS};
        Cursor c= ourDatabase.query(DATABASE_TABLE, col,KEY_ROWID + "-" + l, null, null, null, null);

        if(c != null){
            c.moveToFirst();
            String scale=c.getString(2);
            return scale;
        }
        return null;
    }


    public String getName(long l)  {
        // TODO Auto-generated method stub
        String[] col= new String[]{KEY_ROWID,KEY_NAME,KEY_SCALE , KEY_CONTACTS};
        Cursor c= ourDatabase.query(DATABASE_TABLE, col,KEY_ROWID + "-" + l, null, null, null, null);

        if(c != null){
            c.moveToFirst();
            String name=c.getString(1);
            return name;

        }
        return null;
    }
    public String getContacts(long l)  {
        // TODO Auto-generated method stub
        String[] col= new String[]{KEY_ROWID,KEY_NAME,KEY_SCALE ,KEY_CONTACTS};
        Cursor c= ourDatabase.query(DATABASE_TABLE, col,KEY_ROWID + "-" + l, null, null, null, null);

        if(c != null){
            c.moveToFirst();
            String contacts=c.getString(3);
            return contacts;

        }
        return null;
    }

    public  void updateEntry(long lt, String mName, String mScale ,String mContatcs) {
        // TODO Auto-generated method stub
          ContentValues cvUpdate=new ContentValues();   
          cvUpdate.put(KEY_NAME,mName);
          cvUpdate.put(KEY_SCALE,mScale);
          cvUpdate.put(KEY_CONTACTS,mContatcs );
          ourDatabase.update(DATABASE_TABLE,  cvUpdate, KEY_ROWID + "-" + lt, null);
    }


    public void deleteEntry(long ltt) throws SQLException{
        // TODO Auto-generated method stub
        ourDatabase.delete(DATABASE_TABLE, KEY_ROWID + "=" + ltt,null);

    }
}
package com.example.smscampaign;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import com.example.smscampaign.MainActivity.MyAdapter;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class SmsSend extends Activity implements OnClickListener {
    BroadcastReceiver smsSentReciver, smsSentDelivery;
    static EditText ed1, ed2;
    static int ResultCode = 12;
    static ArrayList<String> sendlist = new ArrayList<String>();
    Button b1, b2, b3, b4;
    TextView txt;
    static StringBuilder conct = new StringBuilder();
    String contacts = "";
    String delim = ";";
    public static String Name;
    TextView ed;
    int i = 0;
    String[] cellArray;
    DataBaseHelp notasdb = new DataBaseHelp(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.smssend);

        ed1 = (EditText) findViewById(R.id.editText1);
        ed2 = (EditText) findViewById(R.id.editText2);
        b1 = (Button) findViewById(R.id.button1);
        b1.setOnClickListener(this);
        b2 = (Button) findViewById(R.id.button2);
        b2.setOnClickListener(this);
        b3 = (Button) findViewById(R.id.button3);
        b3.setOnClickListener(this);
        b4 = (Button) findViewById(R.id.button4);
        b4.setOnClickListener(this);
        txt = (TextView) findViewById(R.id.textnum2);
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        unregisterReceiver(smsSentReciver);
        unregisterReceiver(smsSentDelivery);
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();

        smsSentReciver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context arg0, Intent arg1) {
                // TODO Auto-generated method stub
                switch (getResultCode()) {
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "sms has been sent",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                    Toast.makeText(getBaseContext(), "Generic Fail",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NO_SERVICE:
                    Toast.makeText(getBaseContext(), "No Service",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NULL_PDU:
                    Toast.makeText(getBaseContext(), "Null PDU",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_RADIO_OFF:
                    Toast.makeText(getBaseContext(), "Radio Off",
                            Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;

                }
            }

        };
        smsSentDelivery = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                switch (getResultCode()) {
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "Sms Delivered",
                            Toast.LENGTH_SHORT).show();
                    break;
                case Activity.RESULT_CANCELED:
                    Toast.makeText(getBaseContext(), "Sms not Delivered",
                            Toast.LENGTH_SHORT).show();
                    break;
                }
            }

        };
        registerReceiver(smsSentReciver, new IntentFilter("SMS_SENT"));
        registerReceiver(smsSentDelivery, new IntentFilter("SMS_DELIVERED"));

    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {

        case R.id.button3:

            Intent a = new Intent(SmsSend.this, MainActivity.class);

            startActivityForResult(a, ResultCode);
            break;
        case R.id.button4:
            Intent file = new Intent(SmsSend.this, File_Selecter.class);
            startActivity(file);
            break;

        case R.id.button1:
            if (ed1.getText().toString().length() == 0) {
                ed1.setError("First name is required!");
            } else {
                boolean diditwork1 = true;

                try {
                    String Name = ed1.getText().toString();

                    SmsManager smsManager = SmsManager.getDefault();

                    String msg = ed2.getText().toString();

                    PendingIntent piSend = PendingIntent.getBroadcast(this, 0,
                            new Intent("SMS_SENT"), 0);
                    PendingIntent piDelivered = PendingIntent.getBroadcast(
                            this, 0, new Intent("SMS_DELIVERED"), 0);

                    Log.i("SMS", "contacts: " + contacts);

                    String[] cellArray;

                    contacts = conct.toString();

                    cellArray = contacts.split(";");

                    for (int a1 = 0; a1 < cellArray.length; a1++) {

                        // smsManager.sendTextMessage(cellArray[a1].toString(),
                        // null,
                        // msg, piSend, piDelivered);
                    }
                    DataBaseHandler entry = new DataBaseHandler(SmsSend.this);
                    entry.open();

                    entry.entryCreate(Name, msg , contacts);

                    entry.close();
                } catch (Exception e) {
                    diditwork1 = false;
                    String erroe = e.toString();

                    Dialog d = new Dialog(this);
                    d.setTitle("Dang it!");
                    TextView tv = new TextView(this);
                    tv.setText(erroe);
                    d.setContentView(tv);
                    d.show();

                } finally {
                    if (diditwork1) {
                        Dialog d = new Dialog(this);
                        d.setTitle("Heck Yeah!");
                        TextView tv = new TextView(this);
                        tv.setText("Success");
                        d.setContentView(tv);
                        d.show();
                    }
                }
                ed1.setText("");
                ed2.setText("");
                txt.setText("0");
                conct.delete(0, conct.length());
                break;

            }

        case R.id.button2:

            Log.i("SMS", "Sendlist Size: " + sendlist.size());
              String inputLine = "";
            if (ed1.getText().toString().length() == 0
                    || ed1.getText().toString().length() == 0
        || txt.getText().equals("0")) {
                ed1.setError("First name is required!");
                ed2.setError("Message and contacts are required!");
                txt.setError("Contacts required!");
            } else {
                boolean diditwork1 = true;

                try {
                    String Name = ed1.getText().toString();

                    SmsManager smsManager = SmsManager.getDefault();

                    String msg = ed2.getText().toString();

                    PendingIntent piSend = PendingIntent.getBroadcast(this, 0,
                            new Intent("SMS_SENT"), 0);
                    PendingIntent piDelivered = PendingIntent.getBroadcast(
                            this, 0, new Intent("SMS_DELIVERED"), 0);

                    Log.i("SMS", "contacts: " + contacts);



                    contacts = conct.toString();

                    cellArray = contacts.split(";");

                    for (int a1 = 0; a1 < cellArray.length; a1++) {

                        // smsManager.sendTextMessage(cellArray[a1].toString(),
                        // null,
                        // msg, piSend, piDelivered);

                    }
                    DataBaseHelp entry = new DataBaseHelp(SmsSend.this);
                    entry.open();

                    entry.entryCreate(Name, msg , contacts);

                    entry.close();

                } catch (Exception e) {
                    diditwork1 = false;
                    String erroe = e.toString();

                    Dialog d = new Dialog(this);
                    d.setTitle("Dang it!");
                    TextView tv = new TextView(this);
                    tv.setText(erroe);
                    d.setContentView(tv);
                    d.show();

                } finally {
                    if (diditwork1) {
                        Dialog d = new Dialog(this);
                        d.setTitle("Heck Yeah!");
                        TextView tv = new TextView(this);
                        tv.setText("Success");
                        d.setContentView(tv);
                        d.show();
                    }
                }
                ed1.setText("");
                ed2.setText("");
                txt.setText("0");
                conct.delete(0, conct.length());






                break;
            }
        }
    }


    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (requestCode == ResultCode) {

            if (resultCode == RESULT_OK) {
                // Intent t = getIntent();
                sendlist = data.getStringArrayListExtra("name");
                if (sendlist != null) {

                    for (int i = 0; i < sendlist.size(); i++) {
                        conct.append(sendlist.get(i).toString());
                        conct.append(delim);
                    }

                }

            }

            i = sendlist.size();
            txt.setText(Integer.toString(i));
            if (resultCode == RESULT_CANCELED) {

            }

        }
    }

}
 <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <ListView
                android:id="@+id/listview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black" />
 </ScrollView>
 listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, final View view,
                    int position, long id) {
                TextView tv = (TextView) view.findViewById(R.id.text1);
                String value = tv.getText().toString();
                Intent intent = new Intent(MainActivity.thism,SecondActivity.class);
                intent.putExtra("key",value);
                startActivity(intent);    

            }

        });
 String value = getInent().getStringExtra("key");