Android Case: SMS Encyclopedia

The use of implicit intent jump:

Simple layout:

Main:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</RelativeLayout>

 

item:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView"
    android:textAppearance="?android:attr/textAppearanceLarge" />

 

 

MainActivity:

package org.dreamtech.smsutil;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {

    String objects[] = {
             "Today's wind is very soft, today's flowers are fragrant; today's birds are very happy, today's clouds are full of smiles; today's things are very smooth, today's people are so sweet All the beauty..." ,
             "Girl, life is yours, it will cry to you when you cry, and it will smile to you when you laugh. In a blink of an eye, it's another year, and your birthday is coming. This year, it's still Without my blessings to you, I can't help..." ,
             "The most beautiful voice in the world is the call of my mother; the warmest smile in the world is my mother's warm smile. Mom, forgive me on my birthday. I can't be by your side, on this day, I..." ,
             "Today is your birthday, I wish you: the momentum of making a fortune is as fast as a horse, a thousand miles a day; the speed of development is like a surging river, unstoppable; good things happen like bamboo shoots after a rain, endless stream ;Blessing sent as match..." };

    @Override
    protected  void onCreate (Bundle savedInstanceState) {
         super .onCreate (savedInstanceState);
        setContentView(R.layout.activity_main);

        ListView lv = (ListView) findViewById(R.id.lv);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                R.layout.item, objects);

        lv.setAdapter(adapter);

        lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                String content = objects[position];
                Intent intent = new Intent();
                intent.setAction("android.intent.action.SEND");
                intent.addCategory("android.intent.category.DEFAULT");
                intent.setType("text/plain");
                intent.putExtra("sms_body", content);
                startActivity(intent);
            }
        });
    }

}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324601150&siteId=291194637