700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 成品直播源码推荐 登录和注册两个页面的简单实现

成品直播源码推荐 登录和注册两个页面的简单实现

时间:2024-04-05 12:50:31

相关推荐

成品直播源码推荐 登录和注册两个页面的简单实现

成品直播源码推荐,登录和注册两个页面的简单实现

xml登录界面设计

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="/apk/res/android"xmlns:app="/apk/res-auto"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="注册"android:textSize="35sp"android:gravity="center"android:background="#FF5722"/><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="210dp"android:orientation="horizontal"><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/qq"android:layout_weight="1"android:text="用QQ注册"android:gravity="center"android:textSize="20sp"/><Buttonandroid:layout_width="wrap_content"android:layout_height="210dp"android:background="@drawable/wechat"android:layout_weight="1"android:text="用微信注册"android:textSize="20sp"/></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><ImageViewandroid:id="@+id/yxlg"android:layout_marginTop="12dp"android:layout_marginLeft="80dp"android:layout_width="30dp"android:layout_height="30dp"android:background="@drawable/net"/><TextViewandroid:paddingTop="5dp"android:paddingBottom="5dp"android:id="@+id/yxld"android:layout_width="match_parent"android:layout_height="wrap_content"android:text=" 用邮箱登录"android:gravity="center"android:textSize="35sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:paddingTop="12dp"android:layout_width="wrap_content"android:layout_height="60dp"android:text="名字:"android:gravity="left"android:textSize="25sp"/><EditTextandroid:id="@+id/mz"android:paddingTop="12dp"android:background="@null"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="30sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:paddingTop="12dp"android:layout_width="wrap_content"android:layout_height="60dp"android:text="账号:"android:gravity="left"android:textSize="25sp"/><EditTextandroid:id="@+id/zh"android:paddingTop="12dp"android:background="@null"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="30sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:paddingTop="12dp"android:layout_width="wrap_content"android:layout_height="60dp"android:text="密码:"android:gravity="left"android:textSize="25sp"/><EditTextandroid:password="true"android:id="@+id/mm"android:paddingTop="12dp"android:background="@null"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="30sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:paddingTop="12dp"android:layout_width="wrap_content"android:layout_height="60dp"android:text="性别: "android:gravity="left"android:textSize="25sp"/><RadioGroupandroid:id="@+id/xb"android:layout_marginTop="15dp"android:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"><RadioButtonandroid:id="@+id/nan"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="男"android:textSize="20sp"/><RadioButtonandroid:id="@+id/nu"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="女"android:textSize="20sp"/></RadioGroup></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:paddingTop="12dp"android:layout_width="wrap_content"android:layout_height="60dp"android:text="选择你的爱好:"android:gravity="left"android:textSize="25sp"/><CheckBoxandroid:id="@+id/cg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="唱歌"android:textSize="20sp" /><CheckBoxandroid:id="@+id/tw"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="跳舞"android:textSize="20sp" /><CheckBoxandroid:id="@+id/ds"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="读书"android:textSize="20sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/colorAccent"></LinearLayout><Buttonandroid:id="@+id/btn1"android:layout_width="match_parent"android:layout_height="100dp"android:text="提交"android:textSize="30sp"/></LinearLayout>

注册功能实现

package com.example.registerlogin;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.text.TextUtils;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.CheckBox;import poundButton;import android.widget.EditText;import android.widget.RadioGroup;import android.widget.Toast;public class MainActivity extends AppCompatActivity implements View.OnClickListener,CompoundButton.OnCheckedChangeListener{private EditText mz,zh,mm;private Button btn1;private String name,id,pwd,sex,hobby;private RadioGroup xb;private CheckBox cg,tw,ds;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn1=findViewById(R.id.btn1);mz=findViewById(R.id.mz);zh=findViewById(R.id.mz);mm=findViewById(R.id.mz);cg=findViewById(R.id.cg);tw=findViewById(R.id.tw);ds=findViewById(R.id.ds);xb=findViewById(R.id.xb);btn1.setOnClickListener(MainActivity.this);xb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup radioGroup, int checkedId) {{switch (checkedId){case R.id.nan:sex = "男";break;case R.id.nu:sex="女";break;}}}});}private void getData(){name=mz.getText().toString().trim();id=zh.getText().toString().trim();pwd=mm.getText().toString().trim();}public void onClick(View v) {switch (v.getId()) {case R.id.btn1:getData();if (TextUtils.isEmpty(name)) {Toast.makeText(MainActivity.this, "请输入名字", Toast.LENGTH_SHORT).show();} else if (TextUtils.isEmpty(id)) {Toast.makeText(MainActivity.this, "请输入账号", Toast.LENGTH_SHORT).show();} else if (TextUtils.isEmpty(pwd)) {Toast.makeText(MainActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();} else if (TextUtils.isEmpty(sex)) {Toast.makeText(MainActivity.this, "请输入性别", Toast.LENGTH_SHORT).show();}else if (TextUtils.isEmpty(hobby)) {Toast.makeText(MainActivity.this, "请输入爱好", Toast.LENGTH_SHORT).show();}else {Toast.makeText(MainActivity.this, "注册成功", Log.i("MainActivity", "检测到你的注册信息:" + "名字:" + name + " 邮箱:" + id + " 性别:" + sex+" 爱好:"+hobby));}break;}}public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){String motion =buttonView.getText().toString();if(isChecked){if(!hobby.contains(motion)){hobby = hobby + motion;}}else {if(hobby.contains(motion)){hobby=hobby.replace(motion,"");}}}}

以上就是 成品直播源码推荐,登录和注册两个页面的简单实现,更多内容欢迎关注之后的文章

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。