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

Android開發(fā)之TextView使用intent傳遞信息,實(shí)現(xiàn)注冊界面功能示例

 更新時(shí)間:2019年04月09日 10:45:41   作者:水中魚之1999  
這篇文章主要介紹了Android開發(fā)之TextView使用intent傳遞信息,實(shí)現(xiàn)注冊界面功能,涉及Android使用intent傳值及界面布局等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android開發(fā)之TextView使用intent傳遞信息,實(shí)現(xiàn)注冊界面功能。分享給大家供大家參考,具體如下:

使用intent在活動間傳遞值

首先是 MainActuvity 活動(注冊界面 寫完個(gè)人信息點(diǎn)擊注冊 )

跳轉(zhuǎn)到 In 活動 (通過 intent 獲得 MainActivity 中的信息 )

效果圖如下:

MainActivity 實(shí)現(xiàn):

Java代碼:

public class Home extends AppCompatActivity {
  //用于存放個(gè)人注冊信息
  EditText user_name ;
  EditText user_code ;
  EditText user_year ;
  EditText user_birth ;
  EditText user_phone ;
  //注冊按鈕 點(diǎn)擊跳轉(zhuǎn)
  Button button01 ;
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);//顯示manLayout
    user_name = (EditText) findViewById(R.id.ed_name);
    user_code = (EditText) findViewById(R.id.ed_code);
    user_year = (EditText) findViewById(R.id.ed_year);
    user_birth = (EditText) findViewById(R.id.ed_birth);
    user_phone = (EditText) findViewById(R.id.ed_phone);
    button01 = (Button) findViewById(R.id.bn_01);
    //通過 intent 實(shí)現(xiàn)活動間的信息傳遞
    button01.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent intent01 = new Intent(Home.this,In.class);
        intent01.putExtra("name",user_name.getText().toString());
        intent01.putExtra("code",user_code.getText().toString());
        intent01.putExtra("year",user_year.getText().toString());
        intent01.putExtra("birth",user_birth.getText().toString());
        intent01.putExtra("phone",user_phone.getText().toString());
        startActivity(intent01);
      }
    });
  }
}

XML布局文件:

<TableLayout
  android:id="@+id/root"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:stretchColumns="1">
  <TableRow>
    <TextView
      android:id="@+id/tv_name"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="用戶名"
      android:textSize="16sp"/>
    <EditText
      android:id="@+id/ed_name"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="請?zhí)顚懙顷戀~號"
      android:selectAllOnFocus="true"/>
  </TableRow>
  <TableRow>
    <TextView
      android:id="@+id/tv_code"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="密碼"
      android:textSize="16sp"/>
    <!--android:inputType="numberPassword"表示只能接受數(shù)字密碼-->
    <EditText
      android:id="@+id/ed_code"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="numberPassword"/>
  </TableRow>
  <TableRow>
    <TextView
      android:id="@+id/tv_year"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="年齡"
      android:textSize="16sp"/>
    <!--android:inputType="numberPassword"表示是數(shù)值輸入框-->
    <EditText
      android:id="@+id/ed_year"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="number"/>
  </TableRow>
  <TableRow>
    <TextView
      android:id="@+id/tv_birth"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="生日"
      android:textSize="16sp"/>
    <!--android:inputType="numberPassword"表示日期輸入框-->
    <EditText
      android:id="@+id/ed_birth"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="date"/>
  </TableRow>
  <TableRow>
    <TextView
      android:id="@+id/tv_phone"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="電話號碼"
      android:textSize="16sp"/>
    <!--android:inputType="numberPassword"表示電話號碼輸入框-->
    <EditText
      android:id="@+id/ed_phone"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:selectAllOnFocus="true"
      android:inputType="phone"/>
  </TableRow>
  <Button
    android:id="@+id/bn_01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="注冊"/>
</TableLayout>

In 活動:

Java代碼:

public class In extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_in);
    //獲得MainActivity傳進(jìn)來的數(shù)據(jù)
    Intent intent01 = getIntent();
    //放置傳入的信息
    TextView textView01 = (TextView) findViewById(R.id.In_tv_01);
    textView01.setText( intent01.getStringExtra("name") + "\n"
        + intent01.getStringExtra("code") + "\n"
        + intent01.getStringExtra("year") + "\n"
        + intent01.getStringExtra("birth") + "\n"
        + intent01.getStringExtra("phone") );
  }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".In">
  <!--//放置前一個(gè)活動傳遞進(jìn)來的信息-->
  <TextView
    android:id="@+id/In_tv_01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

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

相關(guān)文章

  • Android App中實(shí)現(xiàn)圖片異步加載的實(shí)例分享

    Android App中實(shí)現(xiàn)圖片異步加載的實(shí)例分享

    這篇文章主要介紹了Android App中實(shí)現(xiàn)圖片異步加載的實(shí)例分享,這樣GridView在加載大量圖片時(shí)便可以延時(shí)分布顯示,需要的朋友可以參考下
    2016-04-04
  • Android BroadcastReceiver傳輸機(jī)制詳解

    Android BroadcastReceiver傳輸機(jī)制詳解

    Android開發(fā)的四大組件分別是:活動(activity),用于表現(xiàn)功能;服務(wù)(service),后臺運(yùn)行服務(wù),不提供界面呈現(xiàn);廣播接受者(Broadcast Receive),勇于接收廣播;內(nèi)容提供者(Content Provider),支持多個(gè)應(yīng)用中存儲和讀取數(shù)據(jù),相當(dāng)于數(shù)據(jù)庫,本篇著重介紹廣播組件
    2023-01-01
  • RecyclerView的使用之多種Item加載布局

    RecyclerView的使用之多種Item加載布局

    本文給大家介石介紹下如何利用RecyclerView實(shí)現(xiàn)多Item布局的加載,多Item布局的加載的意思就是在開發(fā)過程中List的每一項(xiàng)可能根據(jù)需求的不同會加載不同的Layout
    2016-03-03
  • 詳解關(guān)于AndroidQ獲取不到imsi解決方案

    詳解關(guān)于AndroidQ獲取不到imsi解決方案

    這篇文章主要介紹了詳解關(guān)于AndroidQ獲取不到imsi解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 超實(shí)用的Android手勢鎖制作實(shí)例教程

    超實(shí)用的Android手勢鎖制作實(shí)例教程

    這篇文章主要介紹了一個(gè)超實(shí)用的Android手勢鎖制作實(shí)例教程,普通的圓環(huán)形圖標(biāo)變換,在App和系統(tǒng)的鎖屏界面中都可以調(diào)用,需要的朋友可以參考下
    2016-04-04
  • Android Camera變焦編程步驟

    Android Camera變焦編程步驟

    這篇文章主要介紹了Android Camera變焦編程步驟,本文講解了添加Camera權(quán)限、判斷是否支持變焦、修改焦距等步驟,并分別給出了操作代碼,需要的朋友可以參考下
    2015-04-04
  • Android實(shí)現(xiàn)狀態(tài)欄白底黑字效果示例代碼

    Android實(shí)現(xiàn)狀態(tài)欄白底黑字效果示例代碼

    這篇文章主要介紹了Android實(shí)現(xiàn)狀態(tài)欄白底黑字效果的相關(guān)資料,實(shí)現(xiàn)后的效果非常適合日常開發(fā)中使用,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • Android 登錄處理簡單實(shí)例(源碼下載)

    Android 登錄處理簡單實(shí)例(源碼下載)

    這篇文章主要介紹了Android 登錄處理簡單實(shí)例(源碼下載)的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • Android App中使用ListFragment的實(shí)例教程

    Android App中使用ListFragment的實(shí)例教程

    這篇文章主要介紹了Android App中使用ListFragment的實(shí)例教程,ListFragment的內(nèi)容是以列表(list)的形式顯示的Fragment,需要的朋友可以參考下
    2016-05-05
  • 淺談Android應(yīng)用內(nèi)懸浮控件實(shí)踐方案總結(jié)

    淺談Android應(yīng)用內(nèi)懸浮控件實(shí)踐方案總結(jié)

    本篇文章主要介紹了淺談Android應(yīng)用內(nèi)懸浮控件實(shí)踐方案總結(jié),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11

最新評論

北京市| 陆河县| 鸡东县| 梅州市| 新丰县| 嘉祥县| 汕头市| 元氏县| 上虞市| 甘德县| 光泽县| 五华县| 乌兰察布市| 富宁县| 施秉县| 清丰县| 宜昌市| 周口市| 衡水市| 封丘县| 镇原县| 康平县| 安图县| 仪征市| 长葛市| 中西区| 健康| 乌苏市| 怀安县| 吴忠市| 五大连池市| 晋宁县| 阿瓦提县| 璧山县| 平阴县| 广水市| 九江市| 清徐县| 呼图壁县| 保靖县| 噶尔县|