package com.lidaochen.test; import android.content.Intent; import android.os.Bundle; import android.provider.Telephony; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.telephony.SmsManager; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import java.util.ArrayList; public class MainActivity extends{AppCompatActivity String [] Objects = { "Today's very gentle wind, flowers Xiangpiao Miles today; today's birds very happy, today's cloud full of smile; today thing extremely well, people today children so sweet. All the United States ... " , " girl, life is your own, you cry it you cry, you laugh it you laugh. blink of an eye, another year, your birthday is coming this year or ultimately, I bless you, I could not resist ... " , " the world's most beautiful voices, the cries of my mother; the world's most warm smile, a warm smile mother mothers, forgive birthday. I can not stay on your side, in this day, I ... " , " today is your birthday, I wish you: rich momentum as full speed, by leaps and bounds; the pace of development as the surging river, unstoppable; good will happen springing up, flock without a break; send blessings such as race ... " }; @Override protected void the onCreate (Bundle savedInstanceState) { Super .onCreate (savedInstanceState); setContentView (R.layout.activity_main); // find ListView control ListView lv =(The ListView) the findViewById (R.id.lv); // setting data the ArrayAdapter <String> Adapter = new new the ArrayAdapter <String> ( the this , R.layout.item, Objects); // set the data adapter lv.setAdapter (adapter) ; // to set the ListView click event lv.setOnItemClickListener ( new new AdapterView.OnItemClickListener () { @Override public void onItemClick (AdapterView parent, View View, <?> int position, Long the above mentioned id) { // retrieve data entry click String content = Objects [position]; // Go to page messages sent the Intent Intent = new new the Intent (); // Set Action intent.setAction ( "android.intent.action.SEND" ); // set category intent.addCategory ( "android.intent.category .DEFAULT " ); // set the Type intent.setType (" text / Plain " ); // pass data intent.putExtra (" SMS_BODY " , Content); // jump to the page messages transmitted startActivity (Intent); } }); } }
item.xml
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearance" android:id="@+id/tv1" android:text="Hello World!"> </TextView>