activity 张垚

activity 张垚,第1张

概述packagecom.example.myapplication;importandroidx.appcompat.app.AppCompatActivity;importandroid.app.Activity;importandroid.content.Intent;importandroid.os.Bundle;importandroid.view.View;importandroid.widget.Button;importandroid.widget.EditT
package com.example.myapplication;import androIDx.appcompat.app.AppCompatActivity;import androID.app.Activity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.button;import androID.Widget.EditText;import androID.Widget.TextVIEw;import org.w3c.dom.Text;public class MainActivity extends Activity {    @OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.login);    }       public voID login(VIEw vIEw){           EditText ID = (EditText) findVIEwByID(R.ID.edit1);           String s = ID.getText().toString();           Intent intent=new Intent();           intent.setClass(MainActivity.this, TestActivity.class);           intent.putExtra("ID",s);           startActivity(intent);       }}

  

package com.example.myapplication;import androIDx.appcompat.app.AppCompatActivity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.TextVIEw;public class TestActivity extends AppCompatActivity {    @OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.activity_test);        TextVIEw t = (TextVIEw)findVIEwByID(R.ID.text);        Intent intent = this.getIntent();        String ID = intent.getStringExtra("ID");        System.out.println(intent.getStringExtra("ID"));        t.setText(ID);    }}

  

<?xml version="1.0" enCoding="utf-8"?><androIDx.constraintlayout.Widget.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=".MainActivity">    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="Hello World!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintleft_toleftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constrainttop_totopOf="parent" /></androIDx.constraintlayout.Widget.ConstraintLayout>

  

<?xml version="1.0" enCoding="utf-8"?><androIDx.constraintlayout.Widget.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=".MainActivity">    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="Hello World!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintleft_toleftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constrainttop_totopOf="parent" /></androIDx.constraintlayout.Widget.ConstraintLayout>

  

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:orIEntation="vertical" androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"><TextVIEw    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:text=""></TextVIEw>    <ImageVIEw        androID:ID="@+ID/photo"        androID:layout_wIDth="80dp"        androID:layout_height="80dp"        androID:src="@drawable/ic_launcher_background"        androID:layout_centerHorizontal="true"        androID:layout_margintop="200dp"        androID:layout_marginBottom="30dp"></ImageVIEw>    <TextVIEw        androID:ID="@+ID/textVIEw1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_below="@ID/photo"        androID:maxLength="15"        androID:layout_margintop="13dp"        androID:text="账号:"/>    <EditText        androID:ID="@+ID/edit1"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_below="@ID/photo"        androID:layout_toRightOf="@ID/textVIEw1"        androID:hint="请输入您的账号"></EditText>    <TextVIEw        androID:ID="@+ID/textVIEw2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_below="@ID/textVIEw1"        androID:maxLength="20"        androID:layout_margintop="25dp"        androID:text="密码:" />    <EditText        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_below="@ID/textVIEw1"        androID:layout_toRightOf="@ID/textVIEw2"        androID:layout_margintop="10dp"        androID:hint="请输入您的密码"/>    <button        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:ID="@+ID/button"        androID:text="登录"        androID:textcolor="#478595"        androID:layout_below="@ID/textVIEw2"        androID:layout_margintop="20dp"        androID:layout_marginleft="120dp"        androID:layout_centerHorizontal="true"        androID:onClick="login">    </button></relativeLayout>

  

总结

以上是内存溢出为你收集整理的activity 张垚全部内容,希望文章能够帮你解决activity 张垚所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1060198.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存