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

java實(shí)現(xiàn)簡(jiǎn)單注冊(cè)選擇所在城市

 更新時(shí)間:2016年04月06日 15:20:32   作者:格子里的眼眶  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單注冊(cè)選擇所在城市的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java實(shí)現(xiàn)簡(jiǎn)單注冊(cè)選擇所在城市的全部代碼,供大家參考,具體內(nèi)容如下

1.activity_main.xml    

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >
 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="用戶名:"
  />
 <EditText
  android:id="@+id/user"
  android:minWidth="200px"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 <LinearLayout
  android:gravity="center_vertical"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="性別:"
   />
  <RadioGroup
   android:id="@+id/sex"
   android:orientation="horizontal"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
   <RadioButton
    android:id="@+id/radio0"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="true"
    android:text="男"/>
   <RadioButton
    android:id="@+id/radio1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="女"/>
  </RadioGroup>
 </LinearLayout>
<LinearLayout
 android:orientation="vertical"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 <TextView android:id="@+id/textView1"
  android:text="請(qǐng)選擇所在城市:"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"/>
 <Spinner
  android:entries="@array/ctype"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:id="@+id/spinner1"/>
</LinearLayout>
 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="密碼:"/>
 <EditText
  android:id="@+id/pwd"
  android:minWidth="200px"
  android:inputType="textPassword"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="確認(rèn)密碼:"
  />
 <EditText
  android:id="@+id/repwd"
  android:minWidth="200px"
  android:inputType="textPassword"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 <TextView
  android:id="@+id/textView3"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="E-mail地址:" />
 
 <EditText
  android:id="@+id/email"
  android:minWidth="400px"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 
 <Button
  android:id="@+id/submit"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="提交" />
 
 
</LinearLayout>

2.register.xml 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 >
 <TextView
  android:id="@+id/user"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:padding="10px"
  android:text="用戶名:" />
 <TextView
  android:id="@+id/sex"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:padding="10px"
  android:text="性別:"
  />
 <TextView
  android:id="@+id/city"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:padding="10px"
  android:text="城市:"
  />
 
 <TextView
  android:id="@+id/pwd"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:padding="10px"
  android:text="密碼:" />
 
 <TextView
  android:id="@+id/email"
  android:padding="10px"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="E-mail:" />
 <Button
  android:id="@+id/back"
  android:text="返回上一步"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 
</LinearLayout>

3. MainActivity.java    

package com.example.ejcker_llin.myapplication;
 
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;
 
public class MainActivity extends Activity {
 private Button submit;
 private String sex1;
 private String city;
 final int code=0x717;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  submit= (Button) findViewById(R.id.submit);
 
  submit.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    String user=((EditText)findViewById(R.id.user)).getText().toString();
    String pwd=((EditText)findViewById(R.id.pwd)).getText().toString();
    String repwd=((EditText)findViewById(R.id.repwd)).getText().toString();
    String email=((EditText)findViewById(R.id.email)).getText().toString();
    RadioGroup sex= (RadioGroup) findViewById(R.id.sex);
    for(int i=0;i<sex.getChildCount();i++){
     RadioButton r= (RadioButton) sex.getChildAt(i);
     if(r.isChecked()){
      sex1=r.getText().toString();
      break;
     }
    }
    Spinner spinner= (Spinner) findViewById(R.id.spinner1);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
     @Override
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
      city=parent.getItemAtPosition(position).toString();
     }
 
     @Override
     public void onNothingSelected(AdapterView<?> parent) {
 
     }
    });
    if(!"".equals(user)&&!"".equals(pwd)&&!"".equals(email)){
     if(!pwd.equals(repwd)){
      Toast.makeText(MainActivity.this,"兩次輸入的密碼不一致,請(qǐng)重新輸入!",Toast.LENGTH_LONG).show();
      ((EditText) findViewById(R.id.pwd)).setText("");
      ((EditText) findViewById(R.id.repwd)).setText("");
      ((EditText) findViewById(R.id.pwd)).requestFocus();
     }else {
      Intent intent=new Intent(MainActivity.this,RegisterAcivity.class);
      Bundle bundle=new Bundle();
      bundle.putCharSequence("user",user);
      bundle.putCharSequence("sex",sex1);
      bundle.putCharSequence("city",city);
      bundle.putCharSequence("pwd",pwd);
      bundle.putCharSequence("email",email);
      intent.putExtras(bundle);
      //startActivity(intent);
      startActivityForResult(intent,code);
     }
    }else {
     Toast.makeText(MainActivity.this,"請(qǐng)將注冊(cè)信息輸入完整!",Toast.LENGTH_LONG).show();
    }
   }
  });
 }
}

4. RegisterAcivity.java  

package com.example.ejcker_llin.myapplication;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
 
/**
 * Created by Jcker_llin on 2016/4/5.
 */
public class RegisterAcivity extends Activity{
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.register);
  final Intent intent=getIntent();
  Bundle bundle=intent.getExtras();
  TextView user= (TextView) findViewById(R.id.user);
  user.setText("用戶名:"+bundle.getString("user"));
  TextView sex= (TextView) findViewById(R.id.sex);
  sex.setText("性別:"+bundle.getString("sex"));
  TextView city= (TextView) findViewById(R.id.city);
  city.setText("城市:"+bundle.getString("city"));
  TextView pwd= (TextView) findViewById(R.id.pwd);
  pwd.setText("密碼:"+bundle.getString("pwd"));
  TextView email= (TextView) findViewById(R.id.email);
  email.setText("E-mail:"+bundle.getString("email"));
  Button button= (Button) findViewById(R.id.back);
  button.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    setResult(0x717,intent);
    finish();
 
   }
  });
 }
}

5.

6.

7. arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <string-array name="ctype">
  <item>北京</item>
  <item>上海</item>
  <item>廣州</item>
  <item>杭州</item>
  <item>天津</item>
  <item>香港</item>
  <item>重慶</item>
  <item>西安</item>
  <item>其他</item>
 </string-array>
</resources>

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

相關(guān)文章

  • Java并發(fā)編程必備之Future機(jī)制

    Java并發(fā)編程必備之Future機(jī)制

    今天給大家?guī)淼氖顷P(guān)于Java并發(fā)編程的相關(guān)知識(shí),文章圍繞著Java Future機(jī)制展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下
    2021-06-06
  • java實(shí)現(xiàn)對(duì)Hadoop的操作

    java實(shí)現(xiàn)對(duì)Hadoop的操作

    這篇文章主要介紹了java實(shí)現(xiàn)對(duì)Hadoop的操作,通過非常完整詳細(xì)的代碼展示了如何去進(jìn)行一系列操作,包括基本操作,文件讀寫,需要的朋友可以參考下
    2021-07-07
  • 詳解Java Web項(xiàng)目啟動(dòng)執(zhí)行順序

    詳解Java Web項(xiàng)目啟動(dòng)執(zhí)行順序

    這篇文章主要介紹了詳解Java Web項(xiàng)目啟動(dòng)執(zhí)行順序,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-06-06
  • SpringBoot利用EasyExcel實(shí)現(xiàn)導(dǎo)出數(shù)據(jù)

    SpringBoot利用EasyExcel實(shí)現(xiàn)導(dǎo)出數(shù)據(jù)

    EasyExcel是一個(gè)基于Java的、快速、簡(jiǎn)潔、解決大文件內(nèi)存溢出的Excel處理工具,它能讓你在不用考慮性能、內(nèi)存的等因素的情況下,快速完成Excel的讀、寫等功能看,本文就將介紹如何利用EasyExcel實(shí)現(xiàn)導(dǎo)出數(shù)據(jù),需要的朋友可以參考下
    2023-07-07
  • Java實(shí)現(xiàn)多線程的n種方法

    Java實(shí)現(xiàn)多線程的n種方法

    在現(xiàn)代編程中,多線程是一項(xiàng)關(guān)鍵技術(shù),它使得程序能夠同時(shí)執(zhí)行多個(gè)任務(wù),提高了系統(tǒng)的效率和性能,在Java中,有多種方法可以實(shí)現(xiàn)多線程,本文將詳細(xì)介紹幾種常見的Java多線程實(shí)現(xiàn)方法,需要的朋友可以參考下
    2024-11-11
  • springboot中swagger快速啟動(dòng)流程

    springboot中swagger快速啟動(dòng)流程

    這篇文章主要介紹了springboot中的swagger快速啟動(dòng)流程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-09-09
  • 基于SpringMVC接受JSON參數(shù)詳解及常見錯(cuò)誤總結(jié)

    基于SpringMVC接受JSON參數(shù)詳解及常見錯(cuò)誤總結(jié)

    下面小編就為大家分享一篇基于SpringMVC接受JSON參數(shù)詳解及常見錯(cuò)誤總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • Springboot @Value使用代碼實(shí)例

    Springboot @Value使用代碼實(shí)例

    這篇文章主要介紹了Springboot @Value使用代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-11-11
  • 微服務(wù)Springcloud之Feign的基本使用

    微服務(wù)Springcloud之Feign的基本使用

    這篇文章主要介紹了微服務(wù)Springcloud之Feign的基本使用,Spring?Cloud集成Feign并對(duì)其進(jìn)行了增強(qiáng),使Feign支持了Spring?MVC注解,需要的朋友可以參考下
    2023-03-03
  • Spring Boot + Mybatis-Plus實(shí)現(xiàn)多數(shù)據(jù)源的方法

    Spring Boot + Mybatis-Plus實(shí)現(xiàn)多數(shù)據(jù)源的方法

    這篇文章主要介紹了Spring Boot + Mybatis-Plus實(shí)現(xiàn)多數(shù)據(jù)源的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11

最新評(píng)論

城步| 玛沁县| 三原县| 龙岩市| 石家庄市| 仙桃市| 河东区| 香格里拉县| 泽库县| 鹤壁市| 合水县| 临桂县| 天等县| 宁国市| 柳州市| 泗水县| 嘉祥县| 阿拉善右旗| 肇州县| 衡阳市| 开原市| 龙门县| 额尔古纳市| 寿宁县| 神农架林区| 万州区| 平定县| 芜湖市| 常德市| 福贡县| 青海省| 武义县| 烟台市| 烟台市| 瑞昌市| 青田县| 宣威市| 东兰县| 海淀区| 邛崃市| 大足县|