• 注册登录界面 总结


    1.Androidmanifest

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     3     package="com.example.administrator.myapplication">
     4 
     5     <application
     6         android:allowBackup="true"
     7         android:icon="@mipmap/ic_launcher"
     8         android:label="@string/app_name"
     9         android:supportsRtl="true"
    10         android:theme="@style/AppTheme">
    11 
    12         <activity android:name=".MainActivity">
    13             <intent-filter>
    14                 <action android:name="android.intent.action.MAIN" />
    15                 <category android:name="android.intent.category.LAUNCHER" />
    16             </intent-filter>
    17         </activity>
    18         <activity android:name=".zhuceActivity">
    19         </activity>
    20     </application>
    21 
    22 </manifest>

    2.maniactivity.java

     1 package com.example.administrator.myapplication;
     2 
     3 import android.content.Intent;
     4 import android.support.v7.app.AppCompatActivity;
     5 import android.os.Bundle;
     6 import android.view.View;
     7 
     8 public class MainActivity extends AppCompatActivity {
     9 
    10     @Override
    11     protected void onCreate(Bundle savedInstanceState) {
    12         super.onCreate(savedInstanceState);
    13         setContentView(R.layout.activity_main);
    14     }
    15     //view 代表事件发起
    16     public void bt1_onclick(View v)
    17     {
    18         //带返回的打开 注册Acivity
    19 
    20         //第一步:构造意图
    21 
    22         Intent intent = new Intent(this,zhuceActivity.class);
    23 
    24         startActivityForResult(intent,1);
    25     }
    26 }

    3.zhuceActivity.java

     1 package com.example.administrator.myapplication;
     2 
     3 import android.content.Intent;
     4 import android.support.v7.app.AppCompatActivity;
     5 import android.os.Bundle;
     6 import android.view.View;
     7 import android.widget.EditText;
     8 import android.widget.Toast;
     9 
    10 public class zhuceActivity extends AppCompatActivity {
    11     EditText et_usercode1;
    12     EditText et_password1;
    13     EditText et_username1;
    14     @Override
    15     protected void onCreate(Bundle savedInstanceState) {
    16         super.onCreate(savedInstanceState);
    17         setContentView(R.layout.activity_zhuce);
    18 
    19         et_usercode1 = (EditText)findViewById(R.id.et_usercode_1);
    20         et_usercode1 = (EditText)findViewById(R.id.et_password_1);
    21         et_usercode1 = (EditText)findViewById(R.id.et_username_1);
    22     }
    23     //view 代表事件发起
    24     public void bt1_onclick(View v)
    25     {
    26 
    27         //返回注册信息
    28         //用户代码
    29         String usercode = et_usercode1.getText().toString();
    30         if(usercode==null||usercode.trim().length()==0)
    31         {
    32             Toast.makeText(zhuceActivity.this, "请正确填写用户代码", Toast.LENGTH_LONG).show();
    33 
    34             return;
    35         }
    36         String username = et_username1.getText().toString();
    37         if(username==null||username.trim().length()==0)
    38         {
    39             Toast.makeText(zhuceActivity.this, "请正确填写用户名称", Toast.LENGTH_LONG).show();
    40 
    41             return;
    42         }
    43         String userpassword =et_password1.getText().toString();
    44         if(userpassword==null||userpassword.trim().length()==0)
    45         {
    46             Toast.makeText(zhuceActivity.this, "请正确填写用户名称", Toast.LENGTH_LONG).show();
    47 
    48             return;
    49         }
    50 
    51         Intent intent = new Intent();
    52 
    53         intent.putExtra("usercode",usercode);
    54         intent.putExtra("username",username);
    55         intent.putExtra("userpassword",userpassword);
    56 
    57         setResult(RESULT_OK,intent);
    58 
    59         finish();
    60     }
    61 }

    4.Activity_mani.xml

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:paddingBottom="@dimen/activity_vertical_margin"
     7     android:paddingLeft="@dimen/activity_horizontal_margin"
     8     android:paddingRight="@dimen/activity_horizontal_margin"
     9     android:paddingTop="@dimen/activity_vertical_margin"
    10     tools:context="com.example.administrator.myapplication.MainActivity"
    11     android:orientation="vertical">
    12 
    13     <EditText
    14         android:layout_width="match_parent"
    15         android:layout_height="wrap_content"
    16         android:hint="用户代码"
    17         android:id="@+id/et_usercode"/> //获取密码
    18     <EditText
    19         android:layout_width="match_parent"
    20         android:layout_height="wrap_content"
    21         android:hint="密码"
    22         android:id="@+id/et_password"
    23         android:inputType="textPassword"/>
    24     <LinearLayout
    25         android:layout_width="match_parent"
    26         android:layout_height="wrap_content">
    27         <Button
    28             android:layout_width="0dp"
    29             android:layout_height="wrap_content"
    30             android:layout_weight="1"
    31             android:text="登录"/>
    32         <Button
    33             android:layout_width="0dp"
    34             android:layout_height="wrap_content"
    35             android:layout_weight="1"
    36             android:text="密码"
    37             android:onClick="bt1_onclick"/>
    38     </LinearLayout>
    39 </LinearLayout>

    4.Actvity_zhuce.xml

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:paddingBottom="@dimen/activity_vertical_margin"
     7     android:paddingLeft="@dimen/activity_horizontal_margin"
     8     android:paddingRight="@dimen/activity_horizontal_margin"
     9     android:paddingTop="@dimen/activity_vertical_margin"
    10     tools:context="com.example.administrator.myapplication.zhuceActivity">
    11     <EditText
    12         android:layout_width="match_parent"
    13         android:layout_height="wrap_content"
    14         android:hint="用户代码"
    15         android:id="@+id/et_usercode_1"/>
    16     <EditText
    17         android:layout_width="match_parent"
    18         android:layout_height="wrap_content"
    19         android:hint="用户名称"
    20         android:id="@+id/et_username_1"
    21         android:layout_below="@+id/et_usercode_1"/>
    22     <EditText
    23         android:layout_width="match_parent"
    24         android:layout_height="wrap_content"
    25         android:hint="登录密码"
    26         android:id="@+id/et_password_1"
    27         android:layout_below="@+id/et_username_1"/>
    28     <LinearLayout
    29         android:layout_width="match_parent"
    30         android:layout_height="wrap_content"
    31         android:layout_alignParentBottom="true">
    32         <Button
    33             android:layout_width="0dp"
    34             android:layout_height="wrap_content"
    35             android:layout_weight="1"
    36             android:text="取消"
    37             android:onClick="bt2_onclick"/>
    38         <Button
    39             android:layout_width="0dp"
    40             android:layout_height="wrap_content"
    41             android:layout_weight="1"
    42             android:text="确定"
    43             android:onClick="bt1_onclick"/>
    44     </LinearLayout>
    45 </RelativeLayout>
  • 相关阅读:
    基于密度的optics聚类算法
    unicode编码和utf-8编码详解
    聚类分析之k-prototype算法解析
    python学习笔记之正则表达式1
    聚类分析之模糊C均值算法核心思想
    Matlab编程笔记之GUI程序转exe
    Matlab学习笔记之安装教程
    SVPWM原理分析-基于STM32 MC SDK 5.0
    Allego Quick Reports
    SVPWM-实战
  • 原文地址:https://www.cnblogs.com/TENOKAWA/p/5442096.html
Copyright © 2020-2023  润新知