最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android Activity中使用Intent實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)與參數(shù)傳遞的方法

 更新時(shí)間:2016年07月06日 10:33:25   作者:與時(shí)俱進(jìn)  
這篇文章主要介紹了Android Activity中使用Intent實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)與參數(shù)傳遞的方法,結(jié)合實(shí)例形式簡(jiǎn)單分析了Android中的Activity交互操作相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Android Activity中使用Intent實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)與參數(shù)傳遞的方法。分享給大家供大家參考,具體如下:

新建一個(gè)FirstAvtivity.java

package com.zhuguangwei;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FirstActivity extends Activity {
  private Button myButton;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    myButton = (Button) findViewById(R.id.myButton);
    myButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent intent = new Intent();
        //Intent傳遞參數(shù)
        intent.putExtra("testIntent", "123");
        intent.setClass(FirstActivity.this, SecondActivity.class);
        FirstActivity.this.startActivity(intent);
      }
    });
  }
}

新建第二個(gè)SecondActivity.java

package com.zhuguangwei;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class SecondActivity extends Activity{
  private TextView myTextView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.other);
    //使用Intent對(duì)象得到FirstActivity傳遞來(lái)的參數(shù)
    Intent intent = getIntent();
    String value = intent.getStringExtra("testIntent");
    myTextView = (TextView) findViewById(R.id.myTextView);
    myTextView.setText(value);
  }
}

兩個(gè)Activity都要在AndroidMenifest.xml中注冊(cè)

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android操作SQLite數(shù)據(jù)庫(kù)技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫(kù)操作技巧總結(jié)》、《Android文件操作技巧匯總》、《Android編程開(kāi)發(fā)之SD卡操作方法匯總》、《Android開(kāi)發(fā)入門與進(jìn)階教程》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

延安市| 邓州市| 灯塔市| 修水县| 潜山县| 临高县| 新田县| 顺昌县| 安徽省| 侯马市| 梓潼县| 朝阳市| 昌都县| 周口市| 团风县| 乌兰浩特市| 长宁县| 卢氏县| 日喀则市| 丘北县| 淮阳县| 阜康市| 葵青区| 甘德县| 治县。| 巴楚县| 鹰潭市| 临湘市| 武胜县| 吉木乃县| 搜索| 九江县| 罗平县| 阳原县| 鄱阳县| 鲁山县| 韩城市| 延长县| 个旧市| 资兴市| 阳信县|