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

Android實(shí)現(xiàn)注冊(cè)頁(yè)面

 更新時(shí)間:2022年04月23日 16:04:59   作者:上進(jìn)@李小白  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)注冊(cè)頁(yè)面之監(jiān)聽(tīng)器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文用Android studio制作了簡(jiǎn)單的手機(jī)QQ登錄界面,其中界面的布局采用了線性布局、表格布局(不固定布局方法),并給控件綁定監(jiān)聽(tīng)器,當(dāng)用戶(hù)點(diǎn)擊登陸按鈕時(shí),把用戶(hù)所填寫(xiě)的注冊(cè)內(nèi)容顯示在“注冊(cè)”按鈕下面的文本框內(nèi)。

實(shí)現(xiàn)的效果圖:

代碼:

package com.example.project309;
?
import androidx.appcompat.app.AppCompatActivity;
?
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
?
public class MainActivity extends AppCompatActivity {
? ? EditText name;
? ? EditText password;
? ? RadioButton man;
? ? RadioButton woman;
? ? Button ?show;
? ? TextView shower;
? ? CheckBox auto;
? ? CheckBox remember;
? ? String ?result="";
?
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
? ? ? ? name = findViewById(R.id.name);
? ? ? ? password = findViewById(R.id.password);
? ? ? ? man = findViewById(R.id.man);
? ? ? ? woman = findViewById(R.id.woman);
? ? ? ? show = findViewById(R.id.show);
? ? ? ? shower = findViewById(R.id.shower);
? ? ? ? auto = findViewById(R.id.auto);
? ? ? ? remember = findViewById(R.id.remember);
? ? ? ? show.setOnClickListener(this::onClick);
? ? }
? ? public void onClick(View v){
? ? ? ? String user = name.getText().toString();
? ? ? ? result +="姓名:"+user+"\n";
? ? ? ? String pass =password.getText().toString();
? ? ? ? result +="密碼:"+pass+"\n";
? ? ? ? if(man.isChecked()){
? ? ? ? ? ? result+="性別:"+man.getText().toString()+"\n"+"設(shè)置:";
? ? ? ? }
? ? ? ? if(woman.isChecked()){
? ? ? ? ? ? result+="性別:"+woman.getText().toString()+"\n"+"設(shè)置:";
? ? ? ? }
? ? ? ? if(auto.isChecked()){
? ? ? ? ? ? result+=auto.getText().toString()+" ";
? ? ? ? }
? ? ? ? if(remember.isChecked()){
? ? ? ? ? ? result+=remember.getText().toString()+" ";
? ? ? ? }
? ? ? ?shower.setText(result);
? ? }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
? ? tools:context=".MainActivity">
<LinearLayout
? ? android:layout_width="wrap_content"
? ? android:layout_height="wrap_content"
? ? android:orientation="horizontal">
? ? <ImageView
? ? ? ? android:layout_width="180dp"
? ? ? ? android:layout_height="159dp"
? ? ? ? android:src="@drawable/qq" />
? ? <LinearLayout
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="vertical"
? ? ? ? >
?
? ? <TableLayout
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:id="@+id/table1">
?
? ? ? ? <TableRow>
?
? ? ? ? ? ? <TextView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="用戶(hù)名"
? ? ? ? ? ? ? ? android:textColor="#000000"
? ? ? ? ? ? ? ? android:textSize="20dp" />
?
? ? ? ? ? ? <EditText
? ? ? ? ? ? ? ? android:id="@+id/name"
? ? ? ? ? ? ? ? android:layout_width="150dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content" />
?
? ? ? ? </TableRow>
?
? ? ? ? <TableRow>
? ? ? ? ? ? <TextView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="密碼"
? ? ? ? ? ? ? ? android:textColor="#000000"
? ? ? ? ? ? ? ? android:textSize="20dp" />
? ? ? ? ? ? <EditText
? ? ? ? ? ? ? ? android:id="@+id/password"
? ? ? ? ? ? ? ? android:layout_width="150dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content" />
?
? ? ? ? </TableRow>
? ? ? ?<TableRow>
? ? ? ? ? ? <RadioButton
? ? ? ? ? ? ? ? android:id="@+id/man"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="男" />
?
? ? ? ? ? ? <RadioButton
? ? ? ? ? ? ? ? android:id="@+id/woman"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="女" />
?
? ? ? ?</TableRow>
? ? ? ? <LinearLayout
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:orientation="horizontal"
? ? ? ? ? ? >
? ? ? ? ? ? <CheckBox
? ? ? ? ? ? ? ? android:id="@+id/auto"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:checked="true"
? ? ? ? ? ? ? ? android:text="自動(dòng)登錄"
? ? ? ? ? ? ? ? android:textSize="18dp" />
?
? ? ? ? ? ? <CheckBox
? ? ? ? ? ? ? ? android:id="@+id/remember"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:checked="true"
? ? ? ? ? ? ? ? android:text="記住密碼"
? ? ? ? ? ? ? ? android:textSize="18dp" />
? ? ? ? </LinearLayout>
? ? </TableLayout>
? ? </LinearLayout>
</LinearLayout>
? ? <Button
? ? ? ? android:id="@+id/show"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:text="注冊(cè)"
? ? ? ? android:textSize="20dp"
? ? ? ? />
? ? <TextView
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="300dp"
? ? ? ? android:id="@+id/shower"/>
</LinearLayout>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

积石山| 广州市| 原阳县| 方城县| 芜湖县| 股票| 临洮县| 梁河县| 黄冈市| 塘沽区| 台东县| 天等县| 临夏市| 资源县| 旌德县| 德令哈市| 田林县| 普陀区| 靖宇县| 伊吾县| 永嘉县| 冕宁县| 扎兰屯市| 祁阳县| 富川| 内黄县| 琼中| 诸城市| 安多县| 吕梁市| 湟中县| 镇康县| 家居| 中山市| 建德市| 太湖县| 徐水县| 中西区| 镇原县| 伊金霍洛旗| 桐城市|