Spinner select validation

 

java Code:

package com.rebliss.newrebliss;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.media.Image;
import android.opengl.Visibility;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;


public class ActivityKycVerification extends AppCompatActivity implements View.OnClickListener{

Spinner setspinnerkyc;
Button set_dlbtn,set_voterbtn, btn_next11;
ImageView set_dlimg,set_voterimg,kycverification_back_btn;
String [] setid_proof;
LinearLayout setaadaar,setpan,setdl,setvoterid;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_kyc_verification);
btn_next11= findViewById(R.id.btn_next11);
// kycverification_back_btn=findViewById(R.id.kycverification_back_btn);

// kycverification_back_btn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// finish();
// }
// });

btn_next11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(getApplicationContext(),ActivityBankDetails.class);
startActivity(intent);
}
});

setspinnerkyc=(Spinner) findViewById(R.id.editspinnerkyc);

setid_proof = getResources().getStringArray(R.array.id_proofs);

setaadaar = (LinearLayout) findViewById(R.id.editaadhaar);
setpan = (LinearLayout) findViewById(R.id.editpan);
setvoterid = (LinearLayout) findViewById(R.id.editvoterid);
setdl = (LinearLayout) findViewById(R.id.editdl);

set_dlimg = (ImageView) findViewById(R.id.edit_dlimg);

set_dlbtn = (Button) findViewById(R.id.edit_dlbtn);
set_dlbtn.setOnClickListener(this);

set_voterimg = (ImageView) findViewById(R.id.edit_voterimg);

set_voterbtn = (Button) findViewById(R.id.edit_voterbtn);
set_voterbtn.setOnClickListener(this);


//Request for camera permission
if(ContextCompat.checkSelfPermission(ActivityKycVerification.this,
Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED);
{
ActivityCompat.requestPermissions(ActivityKycVerification.this,
new String[]
{
Manifest.permission.CAMERA
},
100);
}

ArrayAdapter adapter5 = new ArrayAdapter(this, android.R.layout.simple_spinner_item, setid_proof);
adapter5.setDropDownViewResource(android.R.layout.simple_selectable_list_item);
setspinnerkyc.setAdapter(adapter5);

setspinnerkyc.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Object item = parent.getItemAtPosition(position);
if(item.equals("Select Id Proof")) {
setaadaar.setVisibility(View.GONE);
setpan.setVisibility(View.GONE);
setvoterid.setVisibility(View.GONE);
setdl.setVisibility(View.GONE);

}
else if(item.equals("Aadhaar card")){
setaadaar.setVisibility(View.VISIBLE);
setpan.setVisibility(View.GONE);
setvoterid.setVisibility(View.GONE);
setdl.setVisibility(View.GONE);
}
else if(item.equals("Pan card")){
setaadaar.setVisibility(View.GONE);
setpan.setVisibility(View.VISIBLE);
setvoterid.setVisibility(View.GONE);
setdl.setVisibility(View.GONE);
}
else if(item.equals("Voter Id card")){
setaadaar.setVisibility(View.GONE);
setpan.setVisibility(View.GONE);
setvoterid.setVisibility(View.VISIBLE);
setdl.setVisibility(View.GONE);
}
else if(item.equals("Driving license")){
setaadaar.setVisibility(View.GONE);
setpan.setVisibility(View.GONE);
setvoterid.setVisibility(View.GONE);
setdl.setVisibility(View.VISIBLE);
}
}

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

}
});
}

@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.edit_dlbtn:
set_dlbtn();
break;
case R.id.edit_voterbtn:
set_voterbtn();
break;

}
}

private void set_voterbtn() {

Intent j = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(j,101 );
}

private void set_dlbtn() {

Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i,100);
}

@SuppressLint("MissingSuperCall")
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == 100)
//get capture image
{
Bitmap captureimage = (Bitmap) data.getExtras().get("data");
//setcapture image to imageview
set_dlimg.setImageBitmap(captureimage);

}
else if (requestCode == 101)
{
Bitmap captureimage = (Bitmap) data.getExtras().get("data");
//setcapture image to imageview
set_voterimg.setImageBitmap(captureimage);

}
// btn_next11.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Intent intent=new Intent(getApplicationContext(),ActivityBankDetails.class);
// startActivity(intent);
// }
// });
}
}

Xml:


<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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:orientation="vertical"
android:layout_height="match_parent"
tools:context=".ActivityKycVerification">

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

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:background="@drawable/toolbarimg1"
android:layout_height="100dp">

<ImageView
android:id="@+id/kycverification_back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:src="@drawable/ic_baseline_arrow_back_24"
app:tint="@color/white">
</ImageView>

</androidx.appcompat.widget.Toolbar>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/kyc_verification"
android:textSize="30dp"
android:gravity="center"
android:textStyle="bold"
android:textColor="@color/black"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:background="@drawable/search_border"
android:layout_height="wrap_content">

<Spinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/editspinnerkyc"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:id="@+id/editaadhaar"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:visibility="gone"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:background="@drawable/search_border"
android:layout_height="wrap_content">

<EditText
android:layout_width="match_parent"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:hint="@string/enter_aadhaar_number"
android:backgroundTint="@color/white"
android:inputType="number"
android:maxLines="1"
android:maxLength="12"
android:textSize="20dp"
android:layout_height="45dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">

<ImageView
android:layout_width="match_parent"
android:src="@drawable/captcha"
android:layout_height="45dp"
android:layout_marginRight="10dp"
android:layout_weight="1"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/search_border">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/fill_captcha"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:maxLines="1"
android:inputType="text"
android:backgroundTint="@color/white"
android:textColor="@color/black"/>

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">

<androidx.appcompat.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:text="@string/generate_otp"
android:textColor="@color/white"
android:background="@drawable/corner_button1"/>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/search_border">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/fill_otp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:maxLines="1"
android:inputType="number"
android:maxLength="6"
android:backgroundTint="@color/white"
android:textColor="@color/black"/>

</LinearLayout>

</LinearLayout>



</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:id="@+id/editpan"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginTop="30dp"
android:background="@drawable/search_border"
android:layout_height="wrap_content">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/pan_card_number"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:inputType="text"
android:maxLines="1"
android:maxLength="12"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">

<androidx.appcompat.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:text="@string/generate_otp"
android:textColor="@color/white"
android:background="@drawable/corner_button1"/>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/search_border">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/fill_otp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:maxLines="1"
android:inputType="number"
android:maxLength="6"
android:backgroundTint="@color/white"
android:textColor="@color/black"/>

</LinearLayout>

</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:id="@+id/editdl"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginTop="30dp"
android:background="@drawable/search_border"
android:layout_height="wrap_content">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/driving_license_number"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:inputType="text"
android:maxLines="1" />
</LinearLayout>

<ImageView
android:layout_width="150dp"
android:layout_height="100dp"
android:id="@+id/edit_dlimg"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/verification_img"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="45dp"
android:id="@+id/edit_dlbtn"
android:layout_gravity="center"
android:padding="10dp"
android:layout_marginTop="20dp"
android:text="@string/click_img"
android:background="@drawable/corner_button1"
android:textColor="@color/white"
android:textSize="15dp"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:id="@+id/editvoterid"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginTop="30dp"
android:background="@drawable/search_border"
android:layout_height="wrap_content">

<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:hint="@string/voter_id_number"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:backgroundTint="@color/white"
android:textColor="@color/black"
android:inputType="text"
android:maxLines="1" />
</LinearLayout>

<ImageView
android:layout_width="150dp"
android:layout_height="100dp"
android:id="@+id/edit_voterimg"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/verification_img"/>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="45dp"
android:id="@+id/edit_voterbtn"
android:layout_gravity="center"
android:padding="10dp"
android:layout_marginTop="20dp"
android:text="@string/click_img"
android:background="@drawable/btn_border"
android:textColor="@color/white"
android:textSize="15dp"/>
</LinearLayout>




</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:layout_margin="15dp"
android:gravity="center">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_next11"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:background="@drawable/corner_button1"
android:text="@string/submit">

</androidx.appcompat.widget.AppCompatButton>

</LinearLayout>


</LinearLayout>

</androidx.core.widget.NestedScrollView>


String Files:


<string-array name="id_proofs">
<item>Select Id Proof</item>
<item>Aadhaar card</item>
<item>Pan card</item>
<item>Voter Id card</item>
<item>Driving license</item>`
</string-array>








Comments

Popular posts from this blog

Open the Camera Pic The Image send to Server Base64