예제 출처 : https://www.inflearn.com/


안드로이드 발리 (Android Volley)는 구글 I/O 2013에서 첫 등장한 이후로 지속적으로 업데이트 되고 있는

네트워크 라이브러리입니다.

출처: http://eteris.tistory.com/792 [Eteris's Palace]


왼쪽  build.gradle(Module: app)에 들어간 뒤 dependencies부분에

compile ‘com.android.volley:1.0.0’ 을 치고

윗쪽에 Sync Now를 누릅니다.




activity_login.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.kch.proj_manager.LoginActivity">

    <EditText
        android:id="@+id/Textview2"
        android:layout_width="308dp"
        android:layout_height="45dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="ID"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_editor_absoluteX="-8dp" />

    <EditText
        android:id="@+id/textView2"
        android:layout_width="310dp"
        android:layout_height="54dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="password"
        android:inputType="textPassword"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Textview2"
        tools:layout_editor_absoluteX="-10dp" />

    <Button
        android:id="@+id/loginbtn"
        android:layout_width="218dp"
        android:layout_height="65dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="login"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2"
        tools:layout_editor_absoluteX="18dp" />

    <TextView
        android:id="@+id/registerbtn"
        android:layout_width="wrap_content"
        android:layout_height="17dp"
        android:layout_marginTop="8dp"
        android:text="register"
        android:textAppearance="@style/TextAppearance.AppCompat.Button"
        app:layout_constraintTop_toBottomOf="@+id/loginbtn"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>


레이아웃 화면

입력받을수 있는 EditText 2개와 1개의 버튼 그리고 텍스트뷰를 배치하였습니다.



activity_register.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.kch.proj_manager.RegisterActivity">

    <EditText
        android:id="@+id/Textview2"
        android:layout_width="342dp"
        android:layout_height="41dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="id"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/textView2"
        android:layout_width="346dp"
        android:layout_height="44dp"
        android:ems="10"
        android:inputType="textPassword"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="18dp"
        app:layout_constraintTop_toBottomOf="@+id/Textview2" />

    <EditText
        android:id="@+id/nameText"
        android:layout_width="346dp"
        android:layout_height="41dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="name"
        android:inputType="textPersonName"
        app:layout_constraintHorizontal_bias="0.318"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2" />

    <EditText
        android:id="@+id/ageText"
        android:layout_width="340dp"
        android:layout_height="44dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="age"
        android:inputType="textPersonName"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/nameText" />

    <Button
        android:id="@+id/registerbtn"
        android:layout_width="248dp"
        android:layout_height="47dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="register"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/ageText" />
</android.support.constraint.ConstraintLayout>


레이아웃 화면

id, 패스워드, 이름, 나이를 받을 수 있는 EditText 4개와 등록을 하는 버튼이 1개 배치되어있습니다.



activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.kch.proj_manager.MainActivity">

    <TextView
        android:id="@+id/WelcomeMessage"
        android:layout_width="335dp"
        android:layout_height="42dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="33dp"
        android:text="welcome"
        android:textAppearance="@style/TextAppearance.AppCompat.Display1"
        app:layout_constraintHorizontal_bias="0.515"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/idText"
        android:layout_width="333dp"
        android:layout_height="48dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="73dp"
        android:textAppearance="@style/TextAppearance.AppCompat.Display1"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/WelcomeMessage" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="333dp"
        android:layout_height="48dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="132dp"
        android:text="Password"
        android:textAppearance="@style/TextAppearance.AppCompat.Headline"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/WelcomeMessage" />

    <TextView
        android:id="@+id/passwordText"
        android:layout_width="333dp"
        android:layout_height="48dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="195dp"
        android:textAppearance="@style/TextAppearance.AppCompat.Display1"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/WelcomeMessage" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="333dp"
        android:layout_height="48dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="12dp"
        android:text="ID"
        android:textAppearance="@style/TextAppearance.AppCompat.Headline"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/WelcomeMessage" />
</android.support.constraint.ConstraintLayout>


레이아웃 화면






블로그 이미지

가카리

프로그래밍, 취업 및 직장생활, 주식 부동산 재테크 전문 블로그

댓글을 달아 주세요