Home Android MySQL : Insert From EditText,CheckBox,Spinner – Part 3 [XML Layouts]

Android MySQL : Insert From EditText,CheckBox,Spinner – Part 3 [XML Layouts]

Android MySQL : Insert From EditText,CheckBox,Spinner – Part 3 [XML Layouts]




Here we look at our xml layout specifictaions.We have two layouts : activitymain.xml and contentmain.xml.These are generated automatically by android studio if you choose the basic activity template.We shall only modify the contentmain.xml.

 

Series

  1. Part 1 - Introduction.
  2. Part 2 - Java Code
  3. Part 3 - XML Layouts.
  4. Part 4 - PHP Code

 

 

 

SECTION 5 : Our Layouts

 

ActivityMain.xml Layout.

  • Inflated as our activity's view.
  • Includes our content main layout.
  • Contains support.v4 widgets like Cordinatorlayout, appbarlayout, toolbar and our floating action button view.

 

 

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
    tools:context="com.tutorials.hp.mysql_datatypes_save.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

 

ContentMain.xml Layout.

 

  • Lets all our spinner,editexts and checkbox as well as buttons here.

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.tutorials.hp.mysql_datatypes_save.MainActivity"
    tools:showIn="@layout/activity_main">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <android.support.design.widget.TextInputEditText
            android:id="@+id/nameTxt"
            android:hint="Name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:textSize="25dp"
            android:enabled="true"
            android:focusable="true" />

    <LinearLayout
        android:orientation="horizontal"
        android:padding="5dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:textSize="25dp"
            android:text="Propellant"
            android:textStyle="bold"
            android:layout_width="250dp"
            android:layout_height="wrap_content" />
        <Spinner
            android:id="@+id/sp"
            android:textSize="25dp"
            android:textStyle="bold"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        </LinearLayout>

        <LinearLayout
        android:orientation="horizontal"
            android:padding="5dp"
            android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:textSize="25dp"
            android:text="Technology Exists ??"

            android:textStyle="bold"
            android:layout_width="250dp"
            android:layout_height="wrap_content" />

        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="25dp"
            android:id="@+id/techExists"
            android:checked="true" />
        </LinearLayout>

        <RelativeLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <Button android:id="@+id/addBtn"
                android:layout_width="wrap_content"
                android:layout_height="60dp"
                android:text="Save"
                android:clickable="true"
                android:padding="5dp"
                android:background="#009968"
                android:textColor="@android:color/white"
                android:textStyle="bold"
                android:textSize="20dp" />

        </RelativeLayout>


    </LinearLayout>
</RelativeLayout>

 

CREDITS :

Amit Shekhar for AndroidNetworking library.

 

 

KEEP IN TOUCH

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Leave a Comment