最新国产好看的视频,伊人天堂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)聽器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文用Android studio制作了簡(jiǎn)單的手機(jī)QQ登錄界面,其中界面的布局采用了線性布局、表格布局(不固定布局方法),并給控件綁定監(jiān)聽器,當(dāng)用戶點(diǎn)擊登陸按鈕時(shí),把用戶所填寫的注冊(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="用戶名"
? ? ? ? ? ? ? ? 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)論

博野县| 秦皇岛市| 灵璧县| 凉城县| 丽水市| 东乡族自治县| 松阳县| 崇礼县| 黄冈市| 大方县| 吉木乃县| 磐安县| 金乡县| 水城县| 南宫市| 鄄城县| 海口市| 巩留县| 合江县| 连平县| 凌海市| 万源市| 冕宁县| 高陵县| 青龙| 高雄县| 洪洞县| 鄂伦春自治旗| 滕州市| 嘉禾县| 马龙县| 郁南县| 广水市| 祁门县| 东莞市| 怀集县| 南澳县| 永安市| 高碑店市| 运城市| 河北省|