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

Android實(shí)現(xiàn)院系專業(yè)三級(jí)聯(lián)動(dòng)

 更新時(shí)間:2021年03月16日 08:10:32   作者:上帝的寵兒NO1  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)院系專業(yè)三級(jí)聯(lián)動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Android實(shí)現(xiàn)院系專業(yè)三級(jí)聯(lián)動(dòng),供大家參考,具體內(nèi)容如下

設(shè)計(jì)一個(gè)注冊(cè)頁(yè)面

注冊(cè)項(xiàng):用戶名、密碼、學(xué)號(hào)、性別、愛好、學(xué)院、系、專業(yè)。

具體要求如下

1、學(xué)號(hào)只能輸入數(shù)字
2、密碼框要隱藏,8-24位之間
3、性別用單選框,默認(rèn)選中男
4、愛好用多選框,默認(rèn)選中第二個(gè)選項(xiàng)
5、院、系和專業(yè)選擇使用下拉列表框(先院,后系、最后專業(yè)。要求院系專業(yè)之間是聯(lián)動(dòng)的,例如:選中了計(jì)算機(jī)學(xué)院,第二個(gè)系列表框里只能有該學(xué)院的幾個(gè)系,選中了某一個(gè)系,第三個(gè)專業(yè)列表框里只能有該系對(duì)應(yīng)的專業(yè))
6、點(diǎn)擊注冊(cè)按鈕,在TextView中顯示所有注冊(cè)信息,同時(shí)用Toast顯示所有注冊(cè)信息

效果圖:

點(diǎn)擊注冊(cè)按鈕,在TextView中顯示所有注冊(cè)信息,同時(shí)用Toast顯示所有注冊(cè)信息

activity_main.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"
 android:gravity="center"
 tools:context=".MainActivity">
 <ScrollView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:scrollbars="none">
 <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="vertical">
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="用戶名"
   android:textSize="18dp"
   android:background="#E91E63"
   android:padding="8dp"
   />
  <EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/edt1"
   android:hint="請(qǐng)輸入用戶名"
   />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="密碼"
   android:textSize="18dp"
   android:background="#E91E63"
   android:padding="8dp"
   />
  <EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/edt2"
   android:hint="請(qǐng)輸入密碼"
   android:inputType="numberPassword"
   />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="學(xué)號(hào)"
   android:textSize="18dp"
   android:background="#E91E63"
   android:padding="8dp"
   />
  <EditText
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/edt3"
   android:hint="請(qǐng)輸入學(xué)號(hào)"
   android:inputType="number"
   />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="性別"
   android:textSize="18dp"
   />
  <RadioGroup
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/rg1"
   android:orientation="vertical">
   <RadioButton
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/rb1"
   android:text="男"
   android:checked="true"
   />
   <RadioButton
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/rb2"
   android:text="女"
   />
  </RadioGroup>
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="愛好"
   android:textSize="18dp"
   android:layout_marginLeft="30dp"
   />
  <LinearLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   >
   <CheckBox
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="唱歌"
   android:id="@+id/cb1"
   />
   <CheckBox
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="跳舞"
   android:checked="true"
   android:id="@+id/cb2"
   />
   <CheckBox
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="書法"
   android:id="@+id/cb3"
   />
  </LinearLayout>
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="學(xué)院"
   android:textSize="18dp"
   android:background="#4CAF50"
   android:padding="8dp"

   />

  <Spinner
   android:id="@+id/sp1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="系"
   android:textSize="18dp"
   android:background="#4CAF50"
   android:padding="8dp"
   />

  <Spinner
   android:id="@+id/sp2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="專業(yè)"
   android:textSize="18dp"
   android:background="#4CAF50"
   android:padding="8dp" />

  <Spinner
   android:id="@+id/sp3"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />
  </LinearLayout>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <Button
   android:id="@+id/btn1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="注冊(cè)" />
  <Button
   android:id="@+id/btn2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="取消" />
  </LinearLayout>
  <TextView
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/id1"
  android:gravity="center"
  android:background="@color/colorAccent"/>
  <TextView
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/id2"
  android:gravity="center"
  android:background="#FFEB3B"/>
  <TextView
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/id3"
  android:gravity="center"
  android:background="#71BFE3"/>
 </LinearLayout>
 </ScrollView>
</LinearLayout>

代碼:

package com.example.test;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.provider.MediaStore;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
 Spinner sp1,sp2,sp3;
 Button btn1;
 EditText edt1,edt2,edt3;
 RadioGroup rg1;
 CheckBox cb1,cb2,cb3;
 TextView id1,id2,id3;
 static int index;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 final String []college={"數(shù)學(xué)與統(tǒng)計(jì)學(xué)院","化學(xué)材料與工程","輕工科學(xué)技術(shù)學(xué)院","電商與物流學(xué)院","生態(tài)環(huán)境學(xué)院","計(jì)算機(jī)學(xué)院"};
 final String [][]depart=
  {
   {"公共數(shù)學(xué)系","應(yīng)用統(tǒng)計(jì)系","經(jīng)濟(jì)統(tǒng)計(jì)系","數(shù)學(xué)與應(yīng)用數(shù)學(xué)系"},
   {"化學(xué)系","材料科學(xué)與工程系","化妝品系"},
   {"應(yīng)用化學(xué)系","生物工程系"},
   {"物流管理系","信息管理系"},
   {"環(huán)境科學(xué)與工程系"},
   {"計(jì)算機(jī)系"}
  };
 final String [][][]major=
  {
   {{"信息與計(jì)算科學(xué)"},{"應(yīng)用統(tǒng)計(jì)學(xué)"},{"經(jīng)濟(jì)統(tǒng)計(jì)學(xué)"},{"數(shù)據(jù)科學(xué)與大數(shù)據(jù)技術(shù)"}},
   {{"化學(xué)技術(shù)與工程"},{"高分子材料與工程","功能材料"},{"化妝品技術(shù)與工程"}},
   {{"化學(xué)"},{"生物工程"}},
   {{"物流管理","供應(yīng)鏈管理"},{"電子商務(wù)","信息管理與信息系統(tǒng)"}},
   {{"環(huán)境科學(xué)與工程"}},
   {{"計(jì)算機(jī)科學(xué)與技術(shù)","軟件工程","物聯(lián)網(wǎng)工程"}}
  };
 ArrayAdapter<String> colAdapter=new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,college);
 ArrayAdapter<String> depAdapter=new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,depart[0]);
 ArrayAdapter<String> morAdapter=new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,major[0][0]);
 edt1=(EditText)findViewById(R.id.edt1);
 edt2=(EditText)findViewById(R.id.edt2);
 edt3=(EditText)findViewById(R.id.edt3);
 rg1=(RadioGroup) findViewById(R.id.rg1);
 cb1=(CheckBox)findViewById(R.id.cb1);
 cb2=(CheckBox)findViewById(R.id.cb2);
 cb3=(CheckBox)findViewById(R.id.cb3);
 sp1=(Spinner)findViewById(R.id.sp1);
 sp2=(Spinner)findViewById(R.id.sp2);
 sp3=(Spinner)findViewById(R.id.sp3);
 btn1=(Button)findViewById(R.id.btn1);
 id1=(TextView)findViewById(R.id.id1);
 id2=(TextView)findViewById(R.id.id2);
 id3=(TextView)findViewById(R.id.id3);
 sp1.setAdapter(colAdapter);
 sp1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  index=position;
  ArrayAdapter<String> depAdapter=new ArrayAdapter<String>(MainActivity.this,R.layout.support_simple_spinner_dropdown_item,depart[position]);
  sp2.setAdapter(depAdapter);
  }

  @Override
  public void onNothingSelected(AdapterView<?> parent) {

  }
 });
 sp2.setAdapter(depAdapter);
 sp2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  ArrayAdapter<String> morAdapter=new ArrayAdapter<String>(MainActivity.this,R.layout.support_simple_spinner_dropdown_item,major[index][position]);
  sp3.setAdapter(morAdapter);
  }

  @Override
  public void onNothingSelected(AdapterView<?> parent) {

  }
 });
 btn1.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
  String likes=" ";
  String name=edt1.getText().toString();
  String password=edt2.getText().toString();
  String num=edt3.getText().toString();
  String str1="用戶名:"+name+"\n"+"密碼:"+password+"\n"+"學(xué)號(hào):"+num;
  String str2=" ";
  if(password.length()<8||password.length()>24)
  {
   Toast.makeText(MainActivity.this,"密碼需8-24位",Toast.LENGTH_SHORT).show();
  }
  else{
   id1.setText(str1);
  }
  for(int i=0;i<rg1.getChildCount();i++)
  {
   RadioButton r=(RadioButton)rg1.getChildAt(i);
   if(r.isChecked())
   {
   str2="性別:"+r.getText().toString();
   id2.setText(str2);
   break;
   }
  }
  if(cb1.isChecked())
  {
   likes=likes+cb1.getText().toString();
  }
  if(cb2.isChecked())
  {
   likes=likes+cb2.getText().toString();
  }
  if(cb3.isChecked())
  {
   likes=likes+cb3.getText().toString();
  }
  String str3="愛好:"+likes+"\n"+"學(xué)院:"+sp1.getSelectedItem().toString()+"\n"+"系:"+sp2.getSelectedItem().toString()+"\n"+"專業(yè):"+sp3.getSelectedItem().toString();
  Toast.makeText(MainActivity.this,str1+"\n"+str2+"\n"+str3,Toast.LENGTH_SHORT).show();
  id3.setText(str3);
  }
 });
 }
}

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

相關(guān)文章

  • android實(shí)現(xiàn)音樂跳動(dòng)效果的示例代碼

    android實(shí)現(xiàn)音樂跳動(dòng)效果的示例代碼

    這篇文章主要介紹了android實(shí)現(xiàn)音樂跳動(dòng)效果的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Android RecyclerView使用方法解析

    Android RecyclerView使用方法解析

    這篇文章主要為大家詳細(xì)解析了Android RecyclerView使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android ListView添加頭布局和腳布局實(shí)例詳解

    Android ListView添加頭布局和腳布局實(shí)例詳解

    這篇文章主要介紹了Android ListView添加頭布局和腳布局實(shí)例詳解的相關(guān)資料,大家看下效果是否是自己想要實(shí)現(xiàn)的效果,這里附了實(shí)現(xiàn)代碼和實(shí)現(xiàn)效果圖,需要的朋友可以參考下
    2016-11-11
  • Android編程實(shí)現(xiàn)小說(shuō)閱讀器滑動(dòng)效果的方法

    Android編程實(shí)現(xiàn)小說(shuō)閱讀器滑動(dòng)效果的方法

    這篇文章主要介紹了Android編程實(shí)現(xiàn)小說(shuō)閱讀器滑動(dòng)效果的方法,涉及onTouch事件滑動(dòng)效果的相關(guān)實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-10-10
  • Android 中基于TabLayout+ViewPager實(shí)現(xiàn)標(biāo)簽卡效果

    Android 中基于TabLayout+ViewPager實(shí)現(xiàn)標(biāo)簽卡效果

    這篇文章主要介紹了Android 中基于TabLayout+ViewPager實(shí)現(xiàn)標(biāo)簽卡效果,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-12-12
  • Android中超大圖片無(wú)法顯示的問題解決

    Android中超大圖片無(wú)法顯示的問題解決

    最近在工作中發(fā)現(xiàn)一個(gè)問題,在做圖片瀏覽的時(shí)候發(fā)現(xiàn)超大圖圖片無(wú)法顯示,無(wú)奈只能上網(wǎng)找解決方法,后來(lái)通過(guò)測(cè)試找到了解決的方法,下面這篇文章就主要介紹了Android中超大圖無(wú)法顯示的問題解決方法,需要的朋友可以參考借鑒。
    2017-01-01
  • android開發(fā)教程之framework增加字符串資源和圖片等resource資源

    android開發(fā)教程之framework增加字符串資源和圖片等resource資源

    這篇文章主要介紹了android開發(fā)中framework增加字符串資源和圖片等resource資源方法,需要的朋友可以參考下
    2014-02-02
  • 關(guān)于Touch Panel AA區(qū)要做外擴(kuò)的原因解析

    關(guān)于Touch Panel AA區(qū)要做外擴(kuò)的原因解析

    今天小編就為大家分享一篇關(guān)于Touch Panel AA區(qū)要做外擴(kuò)的原因解析,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • Android 超詳細(xì)深刨Activity Result API的使用

    Android 超詳細(xì)深刨Activity Result API的使用

    這篇文章主要介紹了Android開發(fā)中Activity Result API的使用,掌握了它以后你就可以放棄startActivityForResult了,感興趣的朋友一起來(lái)看看吧
    2022-03-03
  • Flutter開發(fā)之路由與導(dǎo)航的實(shí)現(xiàn)

    Flutter開發(fā)之路由與導(dǎo)航的實(shí)現(xiàn)

    這篇文章主要介紹了Flutter開發(fā)之路由與導(dǎo)航的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12

最新評(píng)論

安义县| 云南省| 都匀市| 平顶山市| 吉木乃县| 太原市| 抚松县| 南平市| 沙坪坝区| 察雅县| 筠连县| 中卫市| 民权县| 屏南县| 盐池县| 南川市| 丹阳市| 五原县| 若羌县| 汶上县| 集贤县| 兴山县| 海林市| 南靖县| 鹤山市| 嘉定区| 清苑县| 乐山市| 韩城市| 武安市| 哈尔滨市| 莆田市| 民权县| 平乡县| 福海县| 密云县| 肇东市| 北海市| 青铜峡市| 故城县| 肇东市|