Sunday, 16 June 2019

Develop an android app which displays a form to get following information from user. Username, Password, Email-address, Phone number, Country, State, Interest, Birth Date. Form should be followed by a Button with label “Submit”. When user clicks the button, a message should be displayed to user describing the information entered. Mobile Computing and Wireless Communication (170702) GTU


              

               Code :

          <?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:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              tools:context=".deTails">
           
              <EditText
                  android:id="@+id/txt_unm"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:hint="Enter Username"
                  android:inputType="textPersonName" />
           
              <EditText
                  android:id="@+id/txt_pass"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:hint="Enter Password"
                  android:inputType="textPassword" />
           
              <EditText
                  android:id="@+id/txt_email"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:hint="Enter Email"
                  android:inputType="textEmailAddress" />
           
              <EditText
                  android:id="@+id/txt_phone"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:hint="Enter Phone"
                  android:inputType="phone" />
           
              <Spinner
                  android:id="@+id/country"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:entries="@array/country" />
           
              <Spinner
                  android:id="@+id/state"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:entries="@array/state" />
           
              <EditText
                  android:id="@+id/txt_bdate"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:inputType="date" />
           
              <TextView
                  android:id="@+id/textView"
                  android:layout_width="63dp"
                  android:layout_height="wrap_content"
                  android:text="Intrest:"
                  android:textSize="18sp" />
           
              <CheckBox
                  android:id="@+id/checkBox2"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="Coding"
                  tools:text="Coding" />
           
              <CheckBox
                  android:id="@+id/checkBox"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="Hacking"
                  tools:text="Hacking" />
           
              <CheckBox
                  android:id="@+id/checkBox3"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="Gaming" />
           
              <TextView
                  android:id="@+id/textView2"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" />
           
              <Button
                  android:id="@+id/button"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="Submit" />
           
          </LinearLayout>
           
          package com.example.devang.exhello;
           
          import android.support.v7.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.Spinner;
          import android.widget.Toast;
           
          public class deTails extends AppCompatActivity {
              Button submit;
              EditText umn,pass,bdate,no,email;
              Spinner cou,sta;
              CheckBox i1,i2,i3;
           
              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_de_tails);
           
                  submit = findViewById(R.id.button);
                  umn = findViewById(R.id.txt_unm);
                  pass = findViewById(R.id.txt_pass);
                  bdate = findViewById(R.id.txt_bdate);
                  no = findViewById(R.id.txt_phone);
                  email = findViewById(R.id.txt_email);
           
                  cou = findViewById(R.id.country);
                  sta = findViewById(R.id.state);
           
                  i1 = findViewById(R.id.checkBox);
                  i2 = findViewById(R.id.checkBox2);
                  i3 = findViewById(R.id.checkBox3);
           
                  submit.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      String in="",co,st;
           
                      if(i1.isChecked())
                      {
                          in = "," + i1.getText();
                      }
           
                      if(i2.isChecked())
                      {
                          in = "," + i2.getText();
                      }
           
                      if(i3.isChecked())
                      {
                          in = "," + i3.getText();
                      }
                      co = cou.getSelectedItem().toString();
                      st = sta.getSelectedItem().toString();
           
                      String msg = "Name is: "+umn.getText()+" Password is:"+pass.getText()+"Birthdate is:"+bdate.getText()+
                              "Phone is: "+no.getText()+"Email is:"+email.getText()+"Intrest is: "+in+"Country is:"+co+"State is: "+st;
           
                      Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_LONG).show();
                  }
           
              });

          }
           

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...