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

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

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

本文實(shí)例講述了Android Activity中使用Intent實(shí)現(xiàn)頁面跳轉(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傳遞來的參數(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ù)庫技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》、《Android文件操作技巧匯總》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android開發(fā)入門與進(jìn)階教程》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)

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

相關(guān)文章

最新評(píng)論

黄梅县| 八宿县| 承德县| 舞阳县| 兴国县| 斗六市| 枣阳市| 伊通| 定兴县| 隆子县| 浦县| 康保县| 永修县| 城市| 罗源县| 石林| 彭泽县| 河源市| 通化市| 广饶县| 涞水县| 苏尼特左旗| 常德市| 宜兰县| 江都市| 全南县| 三门县| 双流县| 奉节县| 石门县| 大冶市| 灵宝市| 马鞍山市| 奈曼旗| 大洼县| 兴国县| 遂昌县| 新巴尔虎右旗| 罗城| 互助| 普兰店市|