制作手机短信发送助手

 制作布局界面

一个简单的手机助手需要三个界面

第一个是短信发送的主界面

其次是短信助手的显示界面

最后是TextView的界面

<LinearLayout 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"

    android:orientation="vertical"

    tools:context=".MainActivity" >

 

    <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:gravity="center_horizontal"

        android:text="短信助手"

        android:textColor="#ff0000"

        android:textSize="28sp" />

 

    <Button

        android:onClick="selectSms"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="选择短信"

         />

  <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:id="@+id/tv_content"

        android:text="短信内容"

        android:textColor="#00ff00"

        android:textSize="22sp" />

</LinearLayout>

第二个的代码为

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 

    <ListView

        android:id="@+id/lv"

        android:layout_width="match_parent"

        android:layout_height="match_parent" >

    </ListView>

 

</LinearLayout>

第三个代码为

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:text="haha"

    android:textColor="#0000ff"

    android:textSize="20sp"

    android:layout_height="wrap_content" >

    

 

</TextView>

之后在mianAcctivity中填写代码

public class MainActivity extends Activity {

private TextView tv_content;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

tv_content = (TextView) findViewById(R.id.tv_content);

}

 Public  void  fasong (View view ){

      Intent intent (this,SecondActivity);

   startActivityForResult(intent ,0);

}

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

        If(data!=null){

            String text = data.getStringExtra(text);

              Tv_context.settext(text);

              }

else{

tv_context.settext(“没有duanxin”);

}

super.onActivityResult(requestCode, resultCode, data);

}

之后在src中建立一个新的class 把他命名为SelectSMSActivity.java

Public void SelectSMSActivity  extends Activity{

          private TextView tv;

private String[] smscontents={"羊年大吉","羊年happy","哈哈哈 ,新年快乐","新春快乐","天天发财","彩票中奖","^_^"};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

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

setContentView(R.layout.activity_select_sms);

     lv.setAdapter(newArrayAdapter<String>(this, R.layout.item_textview, smscontents));

}

 制作布局界面

一个简单的手机助手需要三个界面

第一个是短信发送的主界面

其次是短信助手的显示界面

最后是TextView的界面

<LinearLayout 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"

    android:orientation="vertical"

    tools:context=".MainActivity" >

 

    <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:gravity="center_horizontal"

        android:text="短信助手"

        android:textColor="#ff0000"

        android:textSize="28sp" />

 

    <Button

        android:onClick="selectSms"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="选择短信"

         />

  <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:id="@+id/tv_content"

        android:text="短信内容"

        android:textColor="#00ff00"

        android:textSize="22sp" />

</LinearLayout>

第二个的代码为

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 

    <ListView

        android:id="@+id/lv"

        android:layout_width="match_parent"

        android:layout_height="match_parent" >

    </ListView>

 

</LinearLayout>

第三个代码为

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:text="haha"

    android:textColor="#0000ff"

    android:textSize="20sp"

    android:layout_height="wrap_content" >

    

 

</TextView>

之后在mianAcctivity中填写代码

public class MainActivity extends Activity {

private TextView tv_content;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

tv_content = (TextView) findViewById(R.id.tv_content);

}

 Public  void  fasong (View view ){

      Intent intent (this,SecondActivity);

   startActivityForResult(intent ,0);

}

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

        If(data!=null){

            String text = data.getStringExtra(text);

              Tv_context.settext(text);

              }

else{

tv_context.settext(“没有duanxin”);

}

super.onActivityResult(requestCode, resultCode, data);

}

之后在src中建立一个新的class 把他命名为SelectSMSActivity.java

Public void SelectSMSActivity  extends Activity{

          private TextView tv;

private String[] smscontents={"羊年大吉","羊年happy","哈哈哈 ,新年快乐","新春快乐","天天发财","彩票中奖","^_^"};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

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

setContentView(R.layout.activity_select_sms);

     lv.setAdapter(newArrayAdapter<String>(this, R.layout.item_textview, smscontents));

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值