HelloAndroidUpDate

改善:
MainActivity类
<span style="font-family:KaiTi_GB2312;font-size:18px;">package cn.com.bztc.wf.androidupdate;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

   public class MainActivity extends Activity {
	public static final String TAG="MainActivity";
	private EditText etName;
		
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);       
       etName=(EditText) findViewById(R.id.etName);
    }
   public void sayHello(View view){
    	String name = etName.getText().toString();
		Intent intent = new Intent();
		intent.setClass(this,ShowActivity.class);
		/*Bundle bundle = new Bundle();
		bundle.putString("name",name);
		bundle.putInt("age",20);
		intent.putExtras(bundle);*/
		intent.putExtra("name",name);
		intent.putExtra("age",19);
		startActivity(intent);
		finish();
    }
}</span><span style="font-size:32px;">
</span>

ShowActivity类
<span style="font-family:KaiTi_GB2312;font-size:18px;">package cn.com.bztc.wf.androidupdate;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class ShowActivity extends Activity{
	private TextView tvShow;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show);
		Bundle bundle = getIntent().getExtras();
		String name = bundle.getString("name");
		int age = bundle.getInt("age");
		initViews();
		tvShow.setText("你好"+name+"\n"+"你今年"+age+"岁");
	}
	private void initViews() {
		tvShow = (TextView) findViewById(R.id.tvShow);
	}
}</span>
<span style="font-size:32px;">届时多了一个跳转页面命名为show</span>
<pre name="code" class="html"><span style="font-family:KaiTi_GB2312;font-size:18px;"><?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:background="@android:color/darker_gray"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tvShow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout></span>
 
 

运行时界面




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值