Sample For Internship Report
Sample For Internship Report
Sample For Internship Report
Ahmedabad
INTERNSHIP REPORT
DEPARTMENT
OF
COMPUTER ENGINEERING /INFORMATION TECHNOLOGY
Subject Code
:- Branch :-
Sem :-
1|Page
190513116012
Certificate
Date:
Place:
Head of Department
2|Page
190513116012
3|Page
190513116012
Table of Contents
Certificate
Acknowledgement
Internship Certificate
Joining latter
Summary
o Introduction
o Overview of the organization
o What I have Learned
o Conclusion
References
Appendies
4|Page
190513116012
Acknowledgement
I would start by thanking my honorable faculty Mrs. Drashti Darji has provide
me with the necessary guidance and information needed to complete this
internship report . I would like to thank Mr. Darpan Salunke (in- charge of
BrainyBeam technologies Pvt. Ltd.) for giving me technical and non-technical
knowledge and guidance during activation period, and the entire team for
being helpful and support.
Also I would like to thank Mr. Sagar jasani (CEO of BrainyBeams technologies
Pvt. Ltd.) for teaching me all the basic of my task and patiently showing me
every elaborate details and guiding me throughout my internship period. I am
very thankful to “ BrainyBeam Technologies Pvt. Ltd.”.
5|Page
190513116012
Internship Certificate
6|Page
190513116012
Joining latter
6|Pag
e
190613116012
Chapter :- 1
Introduction
What is Android?
Why develop apps for Android?
Android versions
The challenges of Android app development
Learn more
What is Android?
Android is an operating system and programming platform developed by Google for
mobile phones and other mobile devices, such as tablets. It can run on many different
devices from many different manufacturers. Android includes a software development kit
(SDK) that helps you write original code and assemble software modules to create apps
for Android users. Android also provides a marketplace to distribute apps. All together,
Android represents an ecosystem for mobile apps.
7|Page
Enrollment No
The Android home screen can contain several panes of app icons, which launch their
associated apps. Home screen panes can also contain app widgets, which display live,
auto-updating content such as the weather, the user's email inbox, or a news ticker.
Android can also play multimedia content such as music, animation, and video. The figure
above shows app icons on the home screen (left), playing music (center), and displaying
app widgets (right). Along the top of the screen is a status bar, showing information
about the device and its connectivity. The Android home screen may be made up of
several panes, and the user swipes back and forth between the panes.
The Android platform, based on the Linux kernel, is designed primarily for touchscreen
mobile devices such as mobile phones and tablets. Because Android-powered devices are
usually battery-powered, Android is designed to manage processes to keep power
consumption at a minimum, providing longer battery use.
To develop apps using the SDK, you use the Java programming language to develop the
app and Extensible Markup Language (XML) files to describe data resources. By writing
the code in Java and creating a single app binary, you create an app that can run on both
phone and tablet form factors. You can declare your UI in lightweight sets of XML
resources. For example, create one set for parts of the UI that are common to all form
factors, and other sets for features specific to phones or tablets. At runtime, Android
applies the correct resource sets based on the device's screen size, screen density, locale,
and so on.
To help you develop your apps efficiently, Google offers an integrated development
environment (IDE) called Android Studio. It offers advanced features for developing,
debugging, and packaging Android apps. Using Android Studio, you can develop for any
Android-powered device, or create virtual devices that emulate any hardware
configuration.
Android provides a rich development architecture. You don't need to know much about
the components of this architecture, but it is useful to know what is available in the
system for your app to use. The following diagram shows the major components of the
8|Page
Enrollment No
1. Apps: Your apps live at this level, along with core system apps for email, SMS messaging,
calendars, internet browsing, and contacts.
2. Java API framework: All features for Android development, such as UI
components, resource management, and lifecycle management, are available through
application programming interfaces (APIs). You don't need to know the details of how the
APIs work. You only need to learn how to use them.
3. Libraries and Android runtime: Each app runs in its own process, with its own instance of
the Android runtime. Android includes a set of core runtime libraries that provide most of
the functionality of the Java programming language. Many core Android system
components and services are built from native code that require native libraries written
in C and C++. These native libraries are available to apps through the Java API framework.
4. Hardware abstraction layer (HAL): This layer provides standard interfaces that expose
device hardware capabilities to the higher-level Java API framework. The HAL consists of
multiple library modules, each of which implements an interface for a specific type of
hardware component, such as the camera or Bluetooth module.
5. Linux kernel: The foundation of the Android platform is the Linux kernel. The layers above
the Linux kernel rely on the Linux kernel for threading, low-level memory management,
and other underlying functionality. Using a Linux kernel enables Android to take
advantage of Linux-based security features and allows device manufacturers to develop
hardware drivers for a well-known kernel.
9|Page
Enrollment No
Chapter :- 2
Overview of organization
10 | P a g e
Their Services :-
Android Development
iOS Development
IoT Development
Windows Development
Web Development
Enterprise Solutions
11 | P a g e
Chapter :- 3
What I have Learned and Activities
Ans: Hello-world:
Mainactivity.java:
package com.example.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".MainActivity">
12 | P a g e
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
13 | P a g e
Output:
14 | P a g e
Task 2: Splash Screen
Ans:SplashActivity.java
package internship.batch2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
public class SplashActivity extends AppCompatActivity
{ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
getSupportActionBar().hide();
imageView = findViewById(R.id.splash_iv);
}
}
1. activity_splash.xml
<ImageView
android:id="@+id/splash_iv"
15 | P a g e
android:layout_centerInParent="true"
android:background="@drawable/ic_smile_icon"
android:layout_width="120dp"
android:layout_height="120dp"/>
</RelativeLayout>
2. AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.InternshipBatch2">
<activity android:name=".LoginActivity"/>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Output:
16 | P a g e
Task 3 : How to create Login page
ANS: LoginActivity.xml :
<?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:background="@drawable/backgroung"
tools:context=".LoginActivity">
<TextView
android:id="@+id/tv"
android:textStyle="italic|bold"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:textColor="#0B0A0A"
android:textSize="25dp"
android:layout_marginBottom="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CREATE NEW ACCOUNT"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login"
android:textStyle="italic|bold"
android:textColor="#090909"
android:textSize="25dp"
android:text="LOGIN FORM"
android:layout_marginTop="75dp"
android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login"
android:layout_marginTop="30dp"
android:textColor="@color/black"
android:layout_centerHorizontal="true"
android:textColorHint="#9A9595"
android:ems="10"
android:padding="10dp"
android:background="@drawable/custom_border"
android:hint="EMAIL ID" />
<EditText
17 | P a g e
18 | P a g e
android:id="@+id/pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="@+id/email"
android:textColorHint="#9A9595"
android:layout_centerHorizontal="true"
android:hint="PASSWORD"
android:textColor="@color/black"
android:padding="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:inputType="textPassword"/>
<Button
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/pass"
app:backgroundTint="@null"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:text="Login"
android:background="@drawable/custon_button"
android:textSize="18dp"
android:textAllCaps="false"/>
</RelativeLayout>
</RelativeLayout>
LoginActivity.java :
package com.example.splashactivity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
19 | P a g e
public class LoginActivity extends AppCompatActivity
TextView tv,login;
EditText email,pass;
Button sub;
@Override
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().setTitle("Login");
tv = findViewById(R.id.tv);
login = findViewById(R.id.login);
email = findViewById(R.id.email);
pass = findViewById(R.id.pass);
sub = findViewById(R.id.sub);
custom_border.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
20 | P a g e
<item>
<shape>
<solid android:color="@color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</selector>
Custom_button :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
</shape>
</item>
<item>
21 | P a g e
<shape>
</shape>
</item>
</selector>
Output :
22 | P a g e
23 | P a g e
Task 4 :
Ans: SplashActivity.java
24 | P a g e
LoginActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
{EditText email,password;
Button login;
TextView createAccount;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().setTitle("Login");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
email = findViewById(R.id.login_email);
password = findViewById(R.id.login_password);
login= findViewById(R.id.login_button);
createAccount = findViewById(R.id.login_create_account);
createAccount.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view) {
new CommonMethod(LoginActivity.this,SignupActivity.class);
}
});
login.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view) {
if(email.getText().toString().trim().equals("")){ email.set
Error("Email Id Required");
}
else
if(!email.getText().toString().trim().matches(emailPattern)){email.setError("Val
id Email Id Required");
}
25 | P a g e
26 | P a g e
190513116012
else
if(password.getText().toString().trim().equals("")){password.setError("Passwor
d Required");
}
else
if(!password.getText().toString().trim().matches(passwordPattern)){password.
setError("Strong Password Required");
}
else{
if(email.getText().toString().trim().equals("admin@gmail.com") &&
password.getText().toString().trim().equalsIgnoreCase("ADmin@007"))
{System.out.println("Login Successfully");
Log.d("LOGIN", "Login Successfully");
Log.e("LOGIN_ERROR", "Signin
Successfully");
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if(id==android.R.id.home){onBackPr
essed();
}
return super.onOptionsItemSelected(item);
}
}
Activity_login.xml
<?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:background="@drawable/backgroubd"
tools:context=".LoginActivity">
<TextView
android:id="@+id/login_create_account"
27 | P a g e
190513116012
style="@style/bold_20_textview"
28 | P a g e
190513116012
29 | P a g e
190513116012
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginVertical="10dp"
android:text="@string/create_account" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/login_create_account">
<TextView
android:id="@+id/login_title"
style="@style/bold_20_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="@string/login_title" />
<EditText
android:padding="10dp"
android:background="@drawable/custom_border"
android:id="@+id/login_email"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_title"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:hint="Enter Email Id"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/login_password"
android:padding="10dp"
android:background="@drawable/custom_border"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_email"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:hint="Enter Password"
android:inputType="textPassword" />
<Button
android:id="@+id/login_button"
android:background="@drawable/custom_button"
style="@style/bold_18_button”
android:textAllCaps="false"
30 | P a g e
100513116012
android:text="Login"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/login_password"
app:backgroundTint="@null"
android:layout_width="100dp"
android:layout_height="100dp"/>
</RelativeLayout>
</RelativeLayout>
HomeActivity.java
package internship.batch2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class HomeActivity extends AppCompatActivity
{@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("HomeActivity");
}
}
SignUpActivity.java
package internship.batch2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class SignupActivity extends AppCompatActivity
{@Override
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
getSupportActionBar().setTitle("SignUp");
31 | P a g e
190513116012
32 | P a g e
190513116012
33 | P a g e
190513116012
34 | P a g e
190513116012
35 | P a g e
190513116012
Task 5 : sing up
Ans : Android Tutorial Topic-5:- Sign Up
LoginActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
{EditText email,password;
Button login;
TextView createAccount;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().setTitle("Login");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
email = findViewById(R.id.login_email);
password = findViewById(R.id.login_password);
login= findViewById(R.id.login_button);
createAccount = findViewById(R.id.login_create_account);
createAccount.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view) {
36 | P a g e
190513116012
new CommonMethod(LoginActivity.this,SignupActivity.class);
}
});
login.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ if(email.getText().toString().trim().equals("")){
email.setError("Email Id Required");
}
else
if(!email.getText().toString().trim().matches(emailPattern)){email.setError("Vali
d Email Id Required");
}
else
if(password.getText().toString().trim().equals("")){password.setError("Password
Required");
}
else
if(!password.getText().toString().trim().matches(passwordPattern)){password.s
etError("Strong Password Required");
}
else{
if(email.getText().toString().trim().equals("admin@gmail.com") &&
password.getText().toString().trim().equalsIgnoreCase("ADmin@007")) {
System.out.println("Login Successfully");
Log.d("LOGIN", "Login Successfully");
Log.e("LOGIN_ERROR", "Signin Successfully");
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if(id==android.R.id.home){
// onBackPressed();
alertMethod();
}
return super.onOptionsItemSelected(item);
}
@Override
37 | P a g e
190513116012
public void onBackPressed() {
38 | P a g e
190513116012
//super.onBackPressed();
alertMethod();
39 | P a g e
190513116012
}
private void alertMethod() {
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setTitle(getResources().getString(R.string.app_name));
builder.setIcon(R.drawable.smiley_icon);
builder.setMessage("Are You Sure Want To Exit!");
builder.setCancelable(false);
builder.show();
Activity_login.xml
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
40 | P a g e
190513116012
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
{ EditText email,password;
Button login;
TextView createAccount;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().setTitle("Login");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
email = findViewById(R.id.login_email);
password = findViewById(R.id.login_password);
login= findViewById(R.id.login_button);
createAccount = findViewById(R.id.login_create_account);
createAccount.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view) {
new CommonMethod(LoginActivity.this,SignupActivity.class);
}
});
login.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ if(email.getText().toString().trim().equals("")){
email.setError("Email Id Required");
}
else
if(!email.getText().toString().trim().matches(emailPattern)){email.setError("Vali
d Email Id Required");
}
else
if(password.getText().toString().trim().equals("")){password.setError("Password
Required");
}
else
if(!password.getText().toString().trim().matches(passwordPattern)){password.s
etError("Strong Password Required");
}
else{
if(email.getText().toString().trim().equals("admin@gmail.com") &&
password.getText().toString().trim().equalsIgnoreCase("ADmin@007")) {
System.out.println("Login Successfully");
Log.d("LOGIN", "Login Successfully");
Log.e("LOGIN_ERROR", "Signin Successfully");
41 | P a g e
190513116012
42 | P a g e
190513116012
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if(id==android.R.id.home){
// onBackPressed();
alertMethod();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
//super.onBackPressed();
alertMethod();
}
private void alertMethod() {
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setTitle(getResources().getString(R.string.app_name));
builder.setIcon(R.drawable.smiley_icon);
builder.setMessage("Are You Sure Want To Exit!");
builder.setCancelable(false);
44 | P a g e
190513116012
builder.show();
HomeActiity.java
package internship.batch2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("HOME");
}
}
Activity_home.xm
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:background="@drawable/vihar"
tools:context=".HomeActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
SignupActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
45 | P a g e
190513116012
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
EditText name,email,contact,password,confirmPassword,dob;
Button login,signup;
ImageView dobIv;
Spinner spinner;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
getSupportActionBar().setTitle("Sign Up");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
name = findViewById(R.id.signup_name);
email = findViewById(R.id.signup_email);
contact =
findViewById(R.id.signup_contact);
password = findViewById(R.id.signup_password);
confirmPassword = findViewById(R.id.signup_confirm_password);
dob = findViewById(R.id.signup_dob);
dobIv = findViewById(R.id.signup_dob_iv);
login = findViewById(R.id.signup_login);
signup = findViewById(R.id.signup_button);
spinner = findViewById(R.id.signup_spinner);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId(); if(id==android.R.id.home)
{on
BackPressed();
}
return super.onOptionsItemSelected(item);
}
}
Activity_Signup.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="@drawable/vihar"
tools:context=".SignupActivity">
<LinearLayout
46 | P a g e
190513116012
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/signup_name"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/custom_border"
android:hint="Name"
android:padding="10dp" />
<EditText
android:id="@+id/signup_email"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="@+id/signup_contact"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Contact No."
android:inputType="number"
android:maxLength="10"
android:padding="10dp" />
<EditText
android:id="@+id/signup_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Password"
android:inputType="textPassword"
android:padding="10dp" />
<EditText
android:id="@+id/signup_confirm_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
47 | P a g e
190513116012
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Confirm Password"
android:inputType="textPassword"
android:padding="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/signup_dob_iv"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/calendar" />
<EditText
android:id="@+id/signup_dob"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@id/signup_dob_iv"
android:background="@drawable/custom_border"
android:editable="false"
android:hint="Date Of Birth"
android:padding="10dp" />
</RelativeLayout>
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/white"
android:text="Gender" />
<RadioGroup
android:id="@+id/signup_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/signup_male"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
48 | P a g e
190513116012
android:textColor="@color/white"
android:text="Male" />
<RadioButton
android:id="@+id/signup_female"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/white"
android:text="Female" />
<RadioButton
android:id="@+id/signup_transgender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/white"
android:text="Transgender" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:textColor="@color/white"
android:text="City" />
<Spinner
android:id="@+id/signup_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<Button
android:id="@+id/signup_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
49 | P a g e
190513116012
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Login"
app:backgroundTint="@null" />
<Button
android:id="@+id/signup_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Signup"
app:backgroundTint="@null" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Output:-
50 | P a g e
190513116012
51 | P a g e
190513116012
52 | P a g e
190513116012
53 | P a g e
190513116012
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/signup_name"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/custom_border"
android:hint="Name"
android:padding="10dp" />
<EditText
android:id="@+id/signup_email"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="@+id/signup_contact"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Contact No."
android:inputType="number"
android:maxLength="10"
android:padding="10dp" />
<EditText
54 | P a g e
190513116012
android:id="@+id/signup_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Password"
android:inputType="textPassword"
android:padding="10dp" />
<EditText
android:id="@+id/signup_confirm_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Confirm Password"
android:inputType="textPassword"
android:padding="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/signup_dob_iv"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/calendar" />
<EditText
android:id="@+id/signup_dob"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@id/signup_dob_iv"
android:background="@drawable/custom_border"
android:editable="false"
android:hint="Date Of Birth"
android:padding="10dp" />
</RelativeLayout>
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
55 | P a g e
190513116012
android:text="Gender" />
<RadioGroup
android:id="@+id/signup_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/signup_male"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Male" />
<RadioButton
android:id="@+id/signup_female"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Female" />
<RadioButton
android:id="@+id/signup_transgender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transgender" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="City" />
<Spinner
android:popupBackground="@color/gray"
android:background="@color/white"
android:id="@+id/signup_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
56 | P a g e
190513116012
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="State" />
<Spinner
android:popupBackground="@color/gray"
android:background="@color/white"
android:id="@+id/signup_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<Button
android:id="@+id/signup_login"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Login"
app:backgroundTint="@null" />
<Button
android:id="@+id/signup_button"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Signup"
app:backgroundTint="@null" />
</LinearLayout>
</LinearLayout>
</ScrollView>
57 | P a g e
190513116012
2.SignupActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
58 | P a g e
190513116012
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
EditText name,email,contact,password,confirmPassword,dob;
Button login,signup;
ImageView dobIv;
Spinner spinner,state;
59 | P a g e
190513116012
ArrayList<String> arrayList;
ArrayList<String> stateArrayList;
RadioGroup gender;
Calendar calendar;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
60 | P a g e
190513116012
getSupportActionBar().setTitle("Signup");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
name = findViewById(R.id.signup_name);
email = findViewById(R.id.signup_email);
contact =
findViewById(R.id.signup_contact);
password = findViewById(R.id.signup_password);
confirmPassword =
findViewById(R.id.signup_confirm_password); dob =
findViewById(R.id.signup_dob);
dobIv = findViewById(R.id.signup_dob_iv);
login = findViewById(R.id.signup_login);
signup = findViewById(R.id.signup_button);
spinner =
findViewById(R.id.signup_spinner); state =
findViewById(R.id.signup_state);
61 | P a g e
190513116012
gender = findViewById(R.id.signup_gender);
62 | P a g e
190513116012
gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{ @Override
RadioButton rb = findViewById(id);
new CommonMethod(SignupActivity.this,rb.getText().toString());
});
calendar = Calendar.getInstance();
@Override
calendar.set(Calendar.YEAR,i);
63 | P a g e
190513116012
calendar.set(Calendar.MONTH,i1);
calendar.set(Calendar.DAY_OF_MONTH,i2);
dob.setText(dateFormat.format(calendar.getTime()));
};
dobIv.setOnClickListener(new View.OnClickListener()
{ @Override
dialog.getDatePicker().setMaxDate(System.currentTimeMillis());
dialog.show();
64 | P a g e
190513116012
});
stateArrayList.add("Gujarat");
stateArrayList.add("Rajasthan");
stateArrayList.add("Maharastra");
stateAdapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);
state.setAdapter(stateAdapter);
state.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
String s = stateArrayList.get(i);
65 | P a g e
190513116012
new CommonMethod(SignupActivity.this,s);
cityDataSet(i);
@Override
});
signup.setOnClickListener(new View.OnClickListener()
{ @Override
if(name.getText().toString().trim().equalsIgnoreCase("")){
name.setError("Name Required");
66 | P a g e
190513116012
else if(email.getText().toString().trim().equalsIgnoreCase("")){
email.setError("Email Id Required");
else if(!email.getText().toString().trim().matches(emailPattern)){
else if(contact.getText().toString().trim().equalsIgnoreCase("")){
else if(contact.getText().toString().length()<10){
else if(password.getText().toString().trim().equalsIgnoreCase("")){
password.setError("Password Required");
67 | P a g e
190513116012
else if(!password.getText().toString().trim().matches(passwordPattern)){
else if(confirmPassword.getText().toString().trim().equalsIgnoreCase("")){
else if(!
confirmPassword.getText().toString().matches(password.getText().toString())){
else if(dob.getText().toString().trim().equalsIgnoreCase("")){
else if(gender.getCheckedRadioButtonId()==-1){
68 | P a g e
190513116012
else{
new CommonMethod(SignupActivity.this,"Signup
Successfully"); onBackPressed();
});
login.setOnClickListener(new View.OnClickListener()
{ @Override
onBackPressed();
});
69 | P a g e
190513116012
if(i==0) {
arrayList.add("Ahemebad");
arrayList.add("Gandhinagar");
arrayList.add("Rajkot");
arrayList.add("Test");
arrayList.add("Surat");
arrayList.add("Vadodara");
arrayList.set(0, "Ahmedabad");
arrayList.remove(3);
if(i==1){
arrayList.add("Kota");
70 | P a g e
190513116012
arrayList.add("Jaipur");
if(i==2){
arrayList.add("Mumbai");
arrayList.add("Pune");
adapter.setDropDownViewResource(android.R.layout.simple_list_item_checked);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
//String s = cityArray[i];
//String s = String.valueOf(adapterView.getItemAtPosition(i));
71 | P a g e
190513116012
String s = arrayList.get(i);
new CommonMethod(SignupActivity.this,s);
@Override
});
@Override
int id = item.getItemId();
if(id==android.R.id.home){
72 | P a g e
190513116012
onBackPressed();
return super.onOptionsItemSelected(item);
Ouput:
73 | P a g e
190513116012
Task 7
Ans: SignUp.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="#78CAEF"
tools:context=".SignUp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/etname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name : "
android:background="@drawable/custom_border"
android:padding="10dp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:textSize="16dp"/>
<EditText
android:id="@+id/etemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email id : "
android:background="@drawable/custom_border"
android:padding="10dp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:textSize="16dp"
android:inputType="textEmailAddress"/>
<EditText
android:id="@+id/etcont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Cont No. : "
android:background="@drawable/custom_border"
android:padding="10dp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:textSize="16dp"
android:inputType="number"
74 | P a g e
190513116012
android:maxLength="10"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:background="@drawable/custom_border">
<LinearLayout
android:id="@+id/pass_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/ivhide"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_invisible"/>
<ImageView
android:visibility="gone"
android:id="@+id/ivshow"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_eye"/>
</LinearLayout>
<EditText
android:id="@+id/etpass"
android:layout_toLeftOf="@id/pass_layout"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="password : "
android:padding="5dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:textSize="16dp"
android:inputType="textPassword"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:background="@drawable/custom_border"
android:layout_marginTop="10dp"
android:padding="5dp">
<LinearLayout
android:id="@+id/conf_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginHorizontal="5dp">
<ImageView
75 | P a g e
190513116012
android:id="@+id/conhide"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_invisible"/>
<ImageView
android:id="@+id/conshow"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_eye"
android:visibility="gone"/>
</LinearLayout>
<EditText
android:id="@+id/etconpass"
android:layout_toLeftOf="@id/conf_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Confirm password : "
android:background="@color/white"
android:padding="5dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:textSize="16dp"
android:inputType="textPassword"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/ivdob"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/calander"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
<EditText
android:id="@+id/etdob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date Of Birth : "
android:textSize="16dp"
android:textColor="@color/black"
android:textColorHint="#817A7A"
android:background="@drawable/custom_border"
android:padding="10dp"
android:layout_toLeftOf="@id/ivdob"
android:layout_marginRight="10dp"
android:editable="false"/>
</RelativeLayout>
<TextView
android:id="@+id/tvgen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="@color/black"
android:padding="10dp"
76 | P a g e
190513116012
android:text="Gender "
android:textStyle="bold"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"/>
<RadioGroup
android:id="@+id/gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:weightSum="3">
<RadioButton
android:id="@+id/rbmale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Male"/>
<RadioButton
android:id="@+id/rbfemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Female"/>
<RadioButton
android:id="@+id/rbtransgender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transgender"/>
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/tvcity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="City "
android:textSize="20dp"
android:layout_weight="2"
android:textColor="@color/black"
android:textStyle="bold"
android:padding="10dp"/>
<Spinner
android:id="@+id/spinnercity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
77 | P a g e
190513116012
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/tvstate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="State "
android:textSize="20dp"
android:layout_weight="2"
android:textColor="@color/black"
android:textStyle="bold"
android:padding="10dp"/>
<Spinner
android:id="@+id/spinnerState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<Button
app:backgroundTint="@null"
android:id="@+id/btlogin"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/custon_button"
android:text="Login”
android:layout_marginHorizontal="20dp"/>
<Button
app:backgroundTint="@null"
android:id="@+id/btsignup"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/custon_button"
android:text="SignUp"
android:layout_marginHorizontal="20dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
SignUp.java
package com.example.splashactivity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
78 | P a g e
190513116012
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
public class SignUp extends AppCompatActivity {
EditText etname, etemail, etcont, etpass, etconpass, etdob;
ImageView ivdob,ivshow,ivhide,conhide,conshow;
//TextView tvgen,tvcity,tvstate;
Spinner spinnercity, spinnerState;
Button btlogin, btsignup;
//ArrayList arrayList;
//String[] cityArray = {"Vadodara","Amdavad","Gandhinagar","Nadiyad","Surat"};
ArrayList<String> arrayList;
ArrayList<String> stateArrayList;
RadioGroup gender;
Calendar calendar;
String emailpattern = "[a-zA-Z0-9.-_]+@[a-z]+.+[a-z]+";
String passpattern = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{4,}$";
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
getSupportActionBar().setTitle("SignUp");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
etname = findViewById(R.id.etname);
etemail = findViewById(R.id.etemail);
etcont = findViewById(R.id.etcont);
etpass = findViewById(R.id.etpass);
etconpass = findViewById(R.id.etconpass);
etdob = findViewById(R.id.etdob);
ivdob = findViewById(R.id.ivdob);
//tvgen = findViewById(R.id.tvgen);
//tvcity = findViewById(R.id.tvcity);
btlogin = findViewById(R.id.btlogin);
btsignup =
findViewById(R.id.btsignup);
spinnercity = findViewById(R.id.spinnercity);
spinnerState = findViewById(R.id.spinnerState);
gender = findViewById(R.id.gender);
79 | P a g e
190513116012
80 | P a g e
190513116012
ivshow = findViewById(R.id.ivshow);
ivhide = findViewById(R.id.ivhide);
conshow =
findViewById(R.id.conshow); conhide =
findViewById(R.id.conhide);
ivhide.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View v)
{ ivhide.setVisibility(v.GONE);
ivshow.setVisibility(v.VISIBLE);
etpass.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
});
ivshow.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View v)
{ ivhide.setVisibility(v.VISIBLE);
ivshow.setVisibility(v.GONE);
etpass.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
});
conhide.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View v)
{ conhide.setVisibility(v.GONE);
conshow.setVisibility(v.VISIBLE);
etconpass.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
});
conshow.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
{ conhide.setVisibility(v.VISIBLE);
conshow.setVisibility(v.GONE);
etconpass.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
});
gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{@Override
public void onCheckedChanged(RadioGroup radioGroup, int i)
{int id = gender.getCheckedRadioButtonId();
//R.id.rbmale
RadioButton rb = findViewById(id);
new CommonMethod(SignUp.this, rb.getText().toString());
}
});
calendar = Calendar.getInstance();
81 | P a g e
190513116012
82 | P a g e
190513116012
83 | P a g e
190513116012
} else if (etemail.getText().toString().trim().equalsIgnoreCase(""))
{etemail.setError("Email-id Required");
} else if (!etemail.getText().toString().trim().matches(emailpattern))
{etemail.setError("Valid Email-id Required");
} else if (etcont.getText().toString().trim().equalsIgnoreCase(""))
{etcont.setError("Contant no. Required");
} else if (etcont.getText().toString().length() < 10)
{etcont.setError("Valid Contant no. Required");
} else if (etpass.getText().toString().trim().equalsIgnoreCase(""))
{etpass.setError("Password Required");
} else if (!etpass.getText().toString().trim().matches(passpattern))
{etpass.setError("Strong password Required");
} else if (etconpass.getText().toString().trim().equalsIgnoreCase(""))
{etconpass.setError("Comfirm password Required");
} else if (!etconpass.getText().toString().trim().matches(etpass.getText().toString()))
{
etconpass.setError("Passwrd does not matched");
} else if (etdob.getText().toString().trim().equalsIgnoreCase(""))
{etdob.setError("Date Of Birth Required");
} else if (gender.getCheckedRadioButtonId() == -1) {
new CommonMethod(SignUp.this, "Please select gender");
} else {
new CommonMethod(SignUp.this, "SignUp Successfully");
}
}
});
btlogin.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View v)
{onBackPressed();
}
});
}
private void CityDataSet(int position)
{arrayList = new ArrayList<>();
if (position == 0)
{ arrayList.add("Amdavad");
arrayList.add("vadodara");
arrayList.add("Surat");
arrayList.add("Test");
arrayList.add("Nadiyad");
arrayList.add("Gandhinagar");
arrayList.set(0, "Ahemdabad");
arrayList.remove(3);
}
if (position == 1)
{ arrayList.add("Jaipur")
;
84 | P a g e
190513116012
85 | P a g e
190513116012
arrayList.add("Rajasthan");
}
if (position == 2)
{ arrayList.add("Kota");
arrayList.add("Jaipur");
}
ArrayAdapter adapter = new ArrayAdapter(SignUp.this,
android.R.layout.simple_list_item_1, arrayList);
adapter.setDropDownViewResource(android.R.layout.simple_list_item_checked);
spinnercity.setAdapter(adapter);
spinnercity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{String s = arrayList.get(position);
new CommonMethod(SignUp.this,
s);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if (id==android.R.id.home)
{
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
}
HomeActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context=".HomeActivity"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Category"
android:textColor="@color/black"
86 | P a g e
190513116012
87 | P a g e
190513116012
android:textSize="20dp"
android:textStyle="bold"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_RecycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
HomeActivity.java
package com.example.splashactivity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.content.Context;
import android.os.Bundle;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.util.Locale;
public class HomeActivity extends AppCompatActivity
{
RecyclerView recyclerView;
String[] nameArray = {"Vegetables","Fruits","Barries","Chilli"};
int[] imageArray =
{R.drawable.vegetables,R.drawable.fruit,R.drawable.barries,R.drawable.chillie};
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("Dashboard");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.home_RecycleView);
recyclerView.setLayoutManager(new
StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
CategoryAdapter adapter = new
CategoryAdapter(HomeActivity.this,nameArray,imageArray);
recyclerView.setAdapter(adapter);
}
88 | P a g e
1190513116012
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if(id== android.R.id.home);
{
finishAffinity();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{finishAffinity();
//super.onBackPressed();
}
private class CategoryAdapter extends
RecyclerView.Adapter<CategoryAdapter.MyHolder>
{
Context context;
String[] nameArray;
int[] imageArray;
public CategoryAdapter(HomeActivity homeActivity, String[] nameArray, int[]
imageArray) {
this.context = homeActivity;
this.nameArray = nameArray;
this.imageArray = imageArray;
}
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
{View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custm_category,parent,false);
return new MyHolder(view);
}
public class MyHolder extends RecyclerView.ViewHolder
{
ImageView custom_category_img;
TextView custom_category_name;
public MyHolder(@NonNull View itemView)
{super(itemView);
custom_category_name = itemView.findViewById(R.id.custom_category_name);
custom_category_img = itemView.findViewById(R.id.custom_category_img);
}
}
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)
{holder.custom_category_name.setText(nameArray[position]);
holder.custom_category_img.setImageResource(imageArray[position]);
89 | P a g e
190513116012
}
@Override
public int getItemCount()
{ return
nameArray.length;
}
}
}
custom_category.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginHorizontal="5dp"
android:layout_marginVertical="10dp"
app:cardCornerRadius="5dp"
app:cardElevation="5dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/custom_category_img"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="150dp"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray">
<TextView
android:id="@+id/custom_category_name"
android:padding="5dp"
android:textSize="20dp"
android:layout_gravity="bottom"
android:textColor="@color/white"
android:gravity="center"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
</FrameLayout>
</androidx.cardview.widget.CardView>
90 | P a g e
190513116012
91 | P a g e
190513116012
Output:
92 | P a g e
190513116012
93 | P a g e
190513116012
Task 8
Ans : : Home Activity with Search Bar
LoginActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import
com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
94 | P a g e
190513116012
EditText email,password;
Button login;
TextView createAccount;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().setTitle("Login");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
email = findViewById(R.id.login_email);
password = findViewById(R.id.login_password);
login= findViewById(R.id.login_button);
createAccount = findViewById(R.id.login_create_account);
createAccount.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view) {
new CommonMethod(LoginActivity.this,SignupActivity.class);
}
95 | P a g e
190513116012
});
login.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ if(email.getText().toString().trim().equals(""))
{
email.setError("Email Id Required");
}
else if(!
email.getText().toString().trim().matches(emailPattern)){
email.setError("Valid Email Id Required");
}
else
if(password.getText().toString().trim().equals("")){p
assword.setError("Password Required");
}
else if(!
password.getText().toString().trim().matches(passwordPattern)){
password.setError("Strong Password Required");
}
else{
if(email.getText().toString().trim().equals("admin@gmail.com") &&
password.getText().toString().trim().equalsIgnoreCase("ADmin@007"))
{
System.out.println("Login Successfully");
Log.d("LOGIN", "Login Successfully");
96 | P a g e
190513116012
Log.e("LOGIN_ERROR", "Signin Successfully");
97 | P a g e
190513116012
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if(id==android.R.id.home){
98 | P a g e
190513116012
//onBackPressed();
alertMethod();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
//super.onBackPressed();
alertMethod();
}
builder.setPositiveButton(Html.fromHtml("<font
color='#F61C0C'>No</font>"), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{dialogInterface.dismiss();
}
99 | P a g e
190513116012
});
100 | P a g
e
190513116012
builder.setNegativeButton(Html.fromHtml("<font
color='#4CAF50'>Yes</font>"), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{finishAffinity();
}
});
builder.show();
activity_login.xml
101 | P a g
e
190513116012
android:layout_height="match_parent"
android:background="@drawable/backgroubd"
tools:context=".LoginActivity">
<TextView
android:id="@+id/login_create_account"
style="@style/bold_20_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginVertical="10dp"
android:text="@string/create_account" />
<ScrollView
android:layout_above="@id/login_create_account"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/login_title"
style="@style/bold_20_textview"
102 | P a g
e
190513116012
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="@string/login_title" />
<EditText
android:padding="10dp"
android:background="@drawable/custom_border"
android:id="@+id/login_email"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_title"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:hint="Enter Email Id"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/login_password"
android:padding="10dp"
android:background="@drawable/custom_border"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
103 | P a g
e
190513116012
android:layout_below="@id/login_email"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="10dp"
android:hint="Enter Password"
android:inputType="textPassword" />
<Button
android:id="@+id/login_button"
android:background="@drawable/custom_button"
style="@style/bold_18_button"
android:textAllCaps="false"
android:text="Login"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/login_password"
app:backgroundTint="@null"
android:layout_width="100dp"
android:layout_height="100dp"/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
SplashActivity.java
package internship.batch2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
104 | P a g
e
190513116012
import android.os.Bundle;
import
android.os.Handler;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.TextView;
{ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
getSupportActionBar().hide();
imageView = findViewById(R.id.splash_iv);
animation.setDuration(2500);
imageView.startAnimation(animation);
activity_splash.xml
105 | P a g
e
190513116012
106 | P a g
e
190513116012
<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:background="@color/white"
tools:context=".SplashActivity">
<ImageView
android:id="@+id/splash_iv"
android:layout_centerInParent="true"
android:background="@drawable/logo3"
android:layout_width="300dp"
android:layout_height="300dp"/>
</RelativeLayout>
CommonMethod.java
package internship.batch2;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Toast;
107 | P a g
e
190513116012
import
com.google.android.material.snackbar.Snackbar; public
class CommonMethod {
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
message){ Snackbar.make(view,message,Snackbar.LENGTH_SHORT).show
();
}
SignupActivity.java
package internship.batch2;
108 | P a g
e
190513116012
import androidx.annotation.NonNull;
109 | P a g
e
190513116012
import androidx.appcompat.app.AppCompatActivity;
110 | P a g
190513116012
import
android.app.DatePickerDialog;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
EditText name,email,contact,password,confirmPassword,dob;
Button login,signup;
111 | P a g
190513116012
112 | P a g
190513116012
ImageView dobIv,hideIv,showIv,hideConfirmIv,showConfirmIv;
Spinner spinner,state;
//String[] cityArray =
{"Ahmedabad","Gandhinagar","Anand","Surat","Vadodara"};
ArrayList<String> arrayList;
ArrayList<String> stateArrayList;
RadioGroup gender;
Calendar calendar;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
getSupportActionBar().setTitle("Signup");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
name = findViewById(R.id.signup_name);
email = findViewById(R.id.signup_email);
contact =
findViewById(R.id.signup_contact);
password = findViewById(R.id.signup_password);
confirmPassword =
findViewById(R.id.signup_confirm_password);
113 | P a g
190513116012
114 | P a g
190513116012
dob = findViewById(R.id.signup_dob);
dobIv = findViewById(R.id.signup_dob_iv);
login = findViewById(R.id.signup_login);
signup =
findViewById(R.id.signup_button);
spinner = findViewById(R.id.signup_spinner);
state = findViewById(R.id.signup_state);
hideIv = findViewById(R.id.signup_hide_iv);
showIv =
findViewById(R.id.signup_show_iv);
hideConfirmIv = findViewById(R.id.signup_confirm_hide_iv);
showConfirmIv = findViewById(R.id.signup_confirm_show_iv);
hideConfirmIv.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ hideConfirmIv.setVisibility(View.GONE);
showConfirmIv.setVisibility(View.VISIBLE);
confirmPassword.setTransformationMethod(HideReturnsTransfor
mationMethod.getInstance());
}
});
showConfirmIv.setOnClickListener(new View.OnClickListener()
{
115 | P a g
190513116012
@Override
116 | P a g
190513116012
confirmPassword.setTransformationMethod(PasswordTransformati
onMethod.getInstance());
}
});
hideIv.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ hideIv.setVisibility(View.GONE);
showIv.setVisibility(View.VISIBLE);
password.setTransformationMethod(HideReturnsTransformationM
ethod.getInstance());
}
});
showIv.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ hideIv.setVisibility(View.VISIBLE)
;showIv.setVisibility(View.GONE);
password.setTransformationMethod(PasswordTransformationMet
hod.getInstance());
117 | P a g
190513116012
}
});
gender = findViewById(R.id.signup_gender);
gender.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int
i) {
int id = gender.getCheckedRadioButtonId();
//R.id.signup_male
RadioButton rb = findViewById(id);
new
CommonMethod(SignupActivity.this,rb.getText().toString());
}
});
calendar = Calendar.getInstance();
118 | P a g
190513116012
SimpleDateFormat dateFormat =
new SimpleDateFormat("dd-MM-yyyy",
Locale.US);
dob.setText(dateFormat.format(calendar.getTime()));
}
};
dobIv.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ DatePickerDialog dialog = new
DatePickerDialog(SignupActivity.this,date,calendar.get(Calendar.YE
AR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF
_MONTH));
dialog.getDatePicker().setMaxDate(System.currentTimeMillis());
dialog.show();
}
});
119 | P a g
190513116012
120 | P a g
190513116012
stateAdapter.setDropDownViewResource(android.R.layout.simple_
list_item_activated_1);
state.setAdapter(stateAdapter);
state.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView,
View view, int i, long l) {
String s = stateArrayList.get(i);
new CommonMethod(SignupActivity.this,s);
cityDataSet(i);
}
@Override
public void onNothingSelected(AdapterView<?>
adapterView) {
}
});
signup.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ if(name.getText().toString().trim().equalsIgnoreCase("")){
name.setError("Name Required");
}
121 | P a g
190513116012
else
if(email.getText().toString().trim().equalsIgnoreCase("")){
email.setError("Email Id Required");
}
else if(!
email.getText().toString().trim().matches(emailPattern)){
email.setError("Valid Email Id Required");
}
else
if(contact.getText().toString().trim().equalsIgnoreCase("")){
contact.setError("Contact No. Required");
}
else
if(contact.getText().toString().length()<10){ contact.setError("V
alid Contact No. Required");
}
else
if(password.getText().toString().trim().equalsIgnoreCase("")){
password.setError("Password Required");
}
else if(!
password.getText().toString().trim().matches(passwordPattern)){
password.setError("Strong Password Required");
}
else
if(confirmPassword.getText().toString().trim().equalsIgnoreCase(""))
{
confirmPassword.setError("Confirm Password
Required");
122 | P a g
190513116012
}
123 | P a g
190513116012
else if(!
confirmPassword.getText().toString().matches(password.getText
().toString())){
confirmPassword.setError("Password Does Not Match");
}
else
if(dob.getText().toString().trim().equalsIgnoreCase("")){
dob.setError("Date Of Birth Required");
}
else if(gender.getCheckedRadioButtonId()==-1){
new CommonMethod(SignupActivity.this,"Please Select
Gender");
}
else{
new CommonMethod(SignupActivity.this,"Signup
Successfully");
onBackPressed();
}
}
});
login.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{onBackPressed();
}
});
124 | P a g e
190513116012
arrayList.set(0,
"Ahmedabad");
arrayList.remove(3);
}
if(i==1){ arrayList.add("K
ota");
arrayList.add("Jaipur");
}
if(i==2){ arrayList.add("Mu
mbai");
arrayList.add("Pune");
}
ArrayAdapter adapter = new ArrayAdapter(SignupActivity.this,
android.R.layout.simple_list_item_1,arrayList);
125 | P a g e
190513116012
126 | P a g e
190513116012
adapter.setDropDownViewResource(android.R.layout.simple_list_it
em_checked);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView,
View view, int i, long l) {
//String s = cityArray[i];
//String s =
String.valueOf(adapterView.getItemAtPosition(i));
String s = arrayList.get(i);
new CommonMethod(SignupActivity.this,s);
}
@Override
public void onNothingSelected(AdapterView<?>
adapterView) {
}
});
@Override
127 | P a g e
190513116012
activity_signup.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:background="@color/sky_blue"
tools:context=".SignupActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/signup_name"
128 | P a g e
190513116012
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/custom_border"
android:hint="Name"
android:padding="10dp" />
<EditText
android:id="@+id/signup_email"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="@+id/signup_contact"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
129 | P a g e
190513116012
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:hint="Contact No."
android:inputType="number"
android:maxLength="10"
android:padding="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:padding="5dp">
<LinearLayout
android:id="@+id/signup_password_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginHorizontal="5dp"
android:orientation="horizontal">
<ImageView
130 | P a g e
190513116012
android:id="@+id/signup_hide_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_hide" /
>
<ImageView
android:id="@+id/signup_show_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_show"
android:visibility="gone" />
</LinearLayout>
<EditText
android:id="@+id/signup_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/signup_password_layout"
android:background="@color/white"
android:hint="Password"
android:inputType="textPassword"
android:padding="5dp" />
</RelativeLayout>
131 | P a g e
190513116012
132 | P a g e
190513116012
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_border"
android:padding="5dp">
<LinearLayout
android:id="@+id/signup_confirm_password_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginHorizontal="5dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/signup_confirm_hide_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_hide" />
<ImageView
android:id="@+id/signup_confirm_show_iv"
133 | P a g e
190513116012
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_show"
android:visibility="gone" />
</LinearLayout>
<EditText
android:id="@+id/signup_confirm_password"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/signup_confirm_password_layout"
android:background="@color/white"
android:hint="Confirm Password"
android:inputType="textPassword"
android:padding="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp">
134 | P a g e
190513116012
<ImageView
android:id="@+id/signup_dob_iv"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/calendar" />
<EditText
android:id="@+id/signup_dob"
style="@style/medium_16_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@id/signup_dob_iv"
android:background="@drawable/custom_border"
android:editable="false"
android:hint="Date Of Birth"
android:padding="10dp" />
</RelativeLayout>
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
135 | P a g e
190513116012
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:text="Gender" />
<RadioGroup
android:id="@+id/signup_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/signup_male"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Male" />
<RadioButton
android:id="@+id/signup_female"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Female" />
<RadioButton
136 | P a g e
190513116012
android:id="@+id/signup_transgender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transgender" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="City" />
<Spinner
android:id="@+id/signup_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
137 | P a g e
190513116012
android:layout_weight="1"
android:background="@color/white"
android:popupBackground="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="State" />
<Spinner
android:id="@+id/signup_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/white"
138 | P a g e
190513116012
android:popupBackground="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<Button
android:id="@+id/signup_login"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Login"
app:backgroundTint="@null" />
<Button
android:id="@+id/signup_button"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginHorizontal="20dp"
android:background="@drawable/custom_button"
android:text="Signup"
139 | P a g e
190513116012
app:backgroundTint="@null" />
</LinearLayout>
</LinearLayout>
</ScrollView>
HomeActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import
androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import
androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import
android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
140 | P a g e
190513116012
import java.util.ArrayList;
import java.util.Locale;
141 | P a g e
190513116012
{ RecyclerView recyclerView;
String[] nameArray = {"Vegetable", "Fruits", "Berries", "Chilli"};
int[] imageArray = {R.drawable.vegetable, R.drawable.fruits,
R.drawable.berries, R.drawable.chilli};
ArrayList<CategoryList> categoryArrayList;
//SearchView searchView;
//EditText searchView;
AutoCompleteTextView searchView;
CategoryAdapter adapter;
ArrayList<String> arrayList;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("Dashboard");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.home_recyclerview);
recyclerView.setLayoutManager(new
StaggeredGridLayoutManager(2,
StaggeredGridLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
142 | P a g e
190513116012
searchView = findViewById(R.id.home_search);
ArrayAdapter adapter = new ArrayAdapter(HomeActivity.this,
android.R.layout.simple_list_item_1, arrayList);
searchView.setThreshold(1);
searchView.setAdapter(adapter);
/*searchView.addTextChangedListener(new TextWatcher()
{@Override
public void beforeTextChanged(CharSequence
charSequence, int i, int i1, int i2) {
@Override
public void onTextChanged(CharSequence charSequence, int
i, int i1, int i2) {
if(charSequence.toString().trim().equalsIgnoreCase("")){adapter.fi
lter("");
}
else{
adapter.filter(charSequence.toString());
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});*/
143 | P a g e
190513116012
/*searchView.setOnQueryTextListener(new
SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query)
{return false;
}
@Override
public boolean onQueryTextChange(String newText)
{if(newText.trim().equals(""))
{ adapter.filter("");
}
else{
adapter.filter(newText);
}
return false;
}
});*/
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem
item) {
int id = item.getItemId();
if (id == android.R.id.home)
{finishAffinity();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{finishAffinity();
//super.onBackPressed();
}
144 | P a g e
190513116012
Context context;
ArrayList<CategoryList> categoryArrayList;
ArrayList<CategoryList> searchList;
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup
parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_c
ategory, parent, false);
return new MyHolder(view);
}
146 | P a g e
190513116012
}
}
notifyDataSetChanged();
}
{ ImageView imageView;
TextView name;
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int
position) {
holder.name.setText(categoryArrayList.get(position).getCategoryN
ame());
holder.imageView.setImageResource(categoryArrayList.get(positio
n).getCategoryImage());
}
@Override
public int getItemCount()
{ return
categoryArrayList.size();
}
147 | P a g e
190513116012
148 | P a g e
190513116012
Context context;
String[] nameArray;
int[] imageArray;
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup
parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_c
ategory,parent,false);
return new MyHolder(view);
}
{ImageView imageView;
TextView name;
149 | P a g e
190513116012
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int
position) {
holder.name.setText(nameArray[position]);
holder.imageView.setImageResource(imageArray[position]);
}
@Override
public int getItemCount()
{ return nameArray.length;
}
}*/
}
activity_home.xml
<!--<androidx.appcompat.widget.SearchView
android:id="@+id/home_search"
android:background="@drawable/custom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:defaultQueryHint="Search Category/Product"
app:queryHint="Search Category/Product" />-->
<!--<EditText
150 | P a g e
190513116012
android:id="@+id/home_search"
style="@style/medium_16_edittext"
android:hint="Search Category/Product"
android:layout_margin="10dp"
android:padding="10dp"
android:background="@drawable/custom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>-->
<AutoCompleteTextView
android:id="@+id/home_search"
android:hint="Search Category/Product"
android:padding="10dp"
android:background="@drawable/custom_border"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Category" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" /
>
</LinearLayout>
CategoryList.java
package internship.batch2;
151 | P a g e
190513116012
152 | P a g e
190513116012
custom_category.xml
153 | P a g e
190513116012
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginHorizontal="5dp"
android:layout_marginVertical="10dp"
app:cardCornerRadius="5dp"
app:cardElevation="5dp">
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:scaleType="fitXY"
android:id="@+id/custom_category_image"
android:layout_width="match_parent"
android:layout_height="150dp"/>
<FrameLayout
android:background="@color/black_transparent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:textColor="@color/white"
android:layout_gravity="bottom"
android:gravity="center"
android:id="@+id/custom_category_name"
android:padding="5dp"
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
</FrameLayout>
</androidx.cardview.widget.CardView>
AndroidManifest.xml
154 | P a g e
190513116012
Output
155 | P a g e
190513116012
156 | P a g e
190513116012
157 | P a g e
190513116012
Task 9
Ans:
HomeActivity.java
package com.example.ecom;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Locale;
{RecyclerView recyclerView;
String[] nameArray = {"Vegetable", "Fruits", "Berries", "Chilli"};
int[] imageArray = {R.drawable.vegetable, R.drawable.fruits, R.drawable.berries,
R.drawable.chilli};
ArrayList<CategoryList> categoryArrayList;
SearchView searchView;
158 | P a g e
190513116012
CategoryAdapter adapter;
ArrayList<String> arrayList;
RecyclerView productRecyclerview;
ArrayList<ProductList> productArrayList;
ProductAdapter productAdapter;
int[] productImageArray =
{R.drawable.beet,R.drawable.green_chilli,R.drawable.red_chillies,R.drawable.apple,R
.drawable.banana,R.drawable.blue_blueberries,R.drawable.grapes,R.drawable.straw
berry};
@Override
{super.onCreate(savedInstanceState);
159 | P a g e
190513116012
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("Dashboard");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.home_recyclerview);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2,
StaggeredGridLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
list.setCategoryName(nameArray[i]);
list.setCategoryImage(imageArray[i]);
categoryArrayList.add(list);
arrayList.add(nameArray[i]);
}
adapter = new CategoryAdapter(HomeActivity.this, categoryArrayList);
160 | P a g e
190513116012
recyclerView.setAdapter(adapter);
productRecyclerview = findViewById(R.id.home_product_recyclerview);
productRecyclerview.setLayoutManager(new
StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.HORIZONTAL));
productRecyclerview.setItemAnimator(new DefaultItemAnimator());
for(int i=0;i<productNameArray.length;i++){
list.setName(productNameArray[i]);
list.setPrice(priceArray[i]);
list.setUnit(unitArray[i]);
list.setImage(productImageArray[i]);
productArrayList.add(list);
161 | P a g e
190513116012
productRecyclerview.setAdapter(productAdapter);
searchView = findViewById(R.id.home_search);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
{return false;
@Override
{if(newText.trim().equals(""))
{ adapter.filter("");
productAdapter.filter("");
else{
adapter.filter(newText);
productAdapter.filter(newText);
162 | P a g e
190513116012
return false;
});
@Override
{ getMenuInflater().inflate(R.menu.main_menu,menu);
return true;
@Override
{int id = item.getItemId();
if (id == android.R.id.home)
{finishAffinity();
if(id==R.id.main_menu_chat){
163 | P a g e
190513116012
new CommonMethod(HomeActivity.this,MessageActivity.class);
return super.onOptionsItemSelected(item);
@Override
public void onBackPressed()
{finishAffinity();
//super.onBackPressed();
Context context;
ArrayList<CategoryList> categoryArrayList;
ArrayList<CategoryList> searchList;
this.context = homeActivity;
164 | P a g e
190513116012
this.categoryArrayList = categoryArrayList;
searchList.addAll(categoryArrayList);
@NonNull
@Override
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_category, parent,
false);
newText = newText.toLowerCase(Locale.getDefault());
categoryArrayList.clear();
if (newText.length() == 0) {
165 | P a g e
190513116012
categoryArrayList.addAll(searchList);
} else {
{if
(cat.getCategoryName().toLowerCase(Locale.getDefault()).contains(newText)) {
categoryArrayList.add(cat);
}
}
notifyDataSetChanged();
ImageView imageView;
TextView name;
{super(itemView);
imageView = itemView.findViewById(R.id.custom_category_image);
name = itemView.findViewById(R.id.custom_category_name);
166 | P a g e
190513116012
@Override
{ holder.name.setText(categoryArrayList.get(position).getCategoryName());
holder.imageView.setImageResource(categoryArrayList.get(position).getCategoryIag
e());
@Override
{ return
categoryArrayList.size();
Context context;
167 | P a g e
190513116012
168 | P a g e
190513116012
ArrayList<ProductList> productArrayList;
ArrayList<ProductList> searchList;
this.context = homeActivity;
this.productArrayList = productArrayList;
searchList.addAll(productArrayList);
newText = newText.toLowerCase(Locale.getDefault());
productArrayList.clear();
if (newText.length() == 0)
{ productArrayList.addAll(searchList);
169 | P a g e
190513116012
} else {
if (cat.getName().toLowerCase(Locale.getDefault()).contains(newText))
{productArrayList.add(cat);
notifyDataSetChanged();
@NonNull
@Override
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_product_horizontal
,parent,false);
170 | P a g e
190513116012
TextView name,price;
ImageView imageView;
{super(itemView);
name = itemView.findViewById(R.id.custom_product_horizontal_name);
price = itemView.findViewById(R.id.custom_product_horizontal_price);
imageView = itemView.findViewById(R.id.custom_product_horizontal_image);
@Override
holder.imageView.setImageResource(productArrayList.get(position).getImage());
holder.name.setText(productArrayList.get(position).getName());
171 | P a g e
190513116012
holder.price.setText(getResources().getString(R.string.price_symbol)+productArrayLi
st.get(position).getPrice()+"/"+productArrayList.get(position).getUnit());
@Override
{ return
productArrayList.size();
}
}
activity_home.xml
<LinearLayout 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"
172 | P a g e
190513116012
173 | P a g e
190513116012
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".HomeActivity">
<androidx.appcompat.widget.SearchView
android:id="@+id/home_search"
android:background="@drawable/custom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:defaultQueryHint="Search Category/Product"
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Product" />
174 | P a g e
190513116012
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_product_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Category" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
ProductList.java
package internship.batch2;
String name,price,unit;
int image;
public String getName()
{return name;
}
}
public void setPrice(String price) {
175 | P a g e
190513116012
this.price = price;
}
public String getUnit() {
return unit;
}
return image;
}
public void setImage(int image)
{this.image = image;
customproduct_horizontal.xml
176 | P a g e
190513116012
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<ImageView
android:id="@+id/custom_product_horizontal_image"
android:layout_width="match_parent"
android:layout_height="100dp" />
<TextView
android:id="@+id/custom_product_horizontal_name"
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp" />
<TextView
android:id="@+id/custom_product_horizontal_price"
style="@style/bold_16_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp" />
</LinearLayout>
</androidx.cardview>
Output:
177 | P a g e
190513116012
178 | P a g e
190513116012
179 | P a g e
190513116012
Task 10
Ans : HomeActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
180 | P a g e
190513116012
import java.util.ArrayList;
import java.util.Locale;
RecyclerView recyclerView;
String[] nameArray = {"Vegetable", "Fruits", "Berries", "Chilli"};
int[] imageArray = {R.drawable.vegetable, R.drawable.fruits, R.drawable.berries,
R.drawable.chilli};
ArrayList<CategoryList> categoryArrayList;
SearchView searchView;
//EditText searchView;
//AutoCompleteTextView searchView;
CategoryAdapter adapter;
ArrayList<String> arrayList;
RecyclerView productRecyclerview;
ArrayList<ProductList> productArrayList;
ProductAdapter productAdapter;
181 | P a g e
190513116012
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
getSupportActionBar().setTitle("Dashboard");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.home_recyclerview);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2,
StaggeredGridLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
productRecyclerview = findViewById(R.id.home_product_recyclerview);
182 | P a g e
190513116012
productRecyclerview.setLayoutManager(new
StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.HORIZONTAL));
productRecyclerview.setItemAnimator(new DefaultItemAnimator());
searchView = findViewById(R.id.home_search);
/*ArrayAdapter adapter = new ArrayAdapter(HomeActivity.this,
android.R.layout.simple_list_item_1, arrayList);
searchView.setThreshold(1);
searchView.setAdapter(adapter);*/
/*searchView.addTextChangedListener(new TextWatcher()
{@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
{if(charSequence.toString().trim().equalsIgnoreCase("")){
183 | P a g e
190513116012
184 | P a g e
190513116012
adapter.filter("");
}
else{
adapter.filter(charSequence.toString());
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});*/
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{@Override
public boolean onQueryTextSubmit(String query)
{return false;
}
@Override
public boolean onQueryTextChange(String newText)
{if(newText.trim().equals(""))
{ adapter.filter("");
productAdapter.filter("");
}
else{
adapter.filter(newText);
productAdapter.filter(newText);
185 | P a g e
190513116012
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{ getMenuInflater().inflate(R.menu.main_menu,menu);
return true;
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if (id == android.R.id.home)
{finishAffinity();
}
if(id==R.id.main_menu_chat){
new CommonMethod(HomeActivity.this,MessageActivity.class);
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{finishAffinity();
//super.onBackPressed();
}
186 | P a g e
190513116012
Context context;
ArrayList<CategoryList> categoryArrayList;
ArrayList<CategoryList> searchList;
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_category, parent,
false);
return new MyHolder(view);
}
} else {
for (CategoryList cat : searchList) {
187 | P a g e
190513116012
if
(cat.getCategoryName().toLowerCase(Locale.getDefault()).contains(newText)) {
categoryArrayList.add(cat);
}
}
}
notifyDataSetChanged();
}
ImageView imageView;
TextView name;
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)
{ holder.name.setText(categoryArrayList.get(position).getCategoryName());
holder.imageView.setImageResource(categoryArrayList.get(position).getCategoryImage(
));
holder.itemView.setOnClickListener(new View.OnClickListener()
{@Override
188 | P a g e
190513116012
@Override
public int getItemCount()
{ return
categoryArrayList.size();
Context context;
ArrayList<ProductList> productArrayList;
ArrayList<ProductList> searchList;
189 | P a g e
190513116012
this.productArrayList = productArrayList;
190 | P a g e
190513116012
}
}
}
notifyDataSetChanged();
}
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_product_horizontal,pa
rent,false);
return new MyHolder(view);
}
191 | P a g e
190513116012
192 | P a g e
190513116012
TextView name,price;
ImageView imageView;
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)
{ holder.imageView.setImageResource(productArrayList.get(position).getImage());
holder.name.setText(productArrayList.get(position).getName());
holder.price.setText(getResources().getString(R.string.price_symbol)+productArrayList.g
et(position).getPrice()+"/"+productArrayList.get(position).getUnit());
holder.itemView.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ Bundle bundle = new
Bundle();
bundle.putString("name",productArrayList.get(position).getName());
bundle.putString("price",getResources().getString(R.string.price_symbol)+productArrayL
ist.get(position).getPrice()+"/"+productArrayList.get(position).getUnit());
bundle.putInt("image",productArrayList.get(position).getImage());
Intent intent = new Intent(context,ProductDetailActivity.class);
intent.putExtras(bundle);
193 | P a g e
190513116012
context.startActivity(intent);
194 | P a g e
190513116012
}
});
@Override
public int getItemCount()
{ return
productArrayList.size();
Context context;
String[] nameArray;
int[] imageArray;
@NonNull
@Override
195 | P a g e
190513116012
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
196 | P a g e
190513116012
197 | P a g e
190513116012 .
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_category,parent,false);
return new MyHolder(view);
}
ImageView imageView;
TextView name;
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)
{holder.name.setText(nameArray[position]);
holder.imageView.setImageResource(imageArray[position]);
}
@Override
public int getItemCount()
{ return
nameArray.length;
}
}*/
198 | P a g e
190513116012 .
}
199 | P a g e
190513116012
ChatFragment.java
package internship.batch2;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public ChatFragment() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_chat, container, false);
}
}
200 | P a g e
190513116012
ProductActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
RecyclerView recyclerView;
ArrayList<ProductList> arrayList;
ProductAdapter adapter;
201 | P a g e
190513116012
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product);
getSupportActionBar().setTitle("Products");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.product_recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(ProductActivity.this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
202 | P a g e
190513116012
204 | P a g e
190513116012
list.setImage(productImageArray2[i]);
list.setPrice(priceArray2[i]);
list.setUnit(unitArray2[i]);
arrayList.add(list);
}
}
if(iPosition==3)
{ for(int
i=0;i<productNameArray3.length;i++){Prod
uctList list = new ProductList();
list.setName(productNameArray3[i]);
list.setImage(productImageArray3[i]);
list.setPrice(priceArray3[i]);
list.setUnit(unitArray3[i]);
arrayList.add(list);
}
}
adapter = new ProductAdapter(ProductActivity.this,arrayList);
recyclerView.setAdapter(adapter);
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId();
if(id ==
android.R.id.home){onBa
ckPressed();
}
return super.onOptionsItemSelected(item);
}
205 | P a g e
190513116012
206 | P a g e
190513116012
Context context;
ArrayList<ProductList> arrayList;
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_product,parent,false);
return new MyHolder(view);
}
ImageView imageView;
TextView name,price;
208 | P a g e
190513116012
}
}
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)
{ holder.imageView.setImageResource(arrayList.get(position).getImage());
holder.name.setText(arrayList.get(position).getName());
holder.price.setText(getResources().getString(R.string.price_symbol)+arrayList.get(positi
on).getPrice()+"/"+arrayList.get(position).getUnit());
holder.itemView.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View view)
{ Bundle bundle = new
Bundle();
bundle.putString("name",arrayList.get(position).getName());
bundle.putString("price",getResources().getString(R.string.price_symbol)+arrayList.get(p
osition).getPrice()+"/"+arrayList.get(position).getUnit());
bundle.putInt("image",arrayList.get(position).getImage());
Intent intent = new
Intent(context,ProductDetailActivity.class);
intent.putExtras(bundle);
context.startActivity(intent);
}
});
@Override
209 | P a g e
190513116012
public int getItemCount()
210 | P a g e
190513116012
{return arrayList.size();
211 | P a g e
190513116012
}
}
}
ProductDetailsActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
ImageView imageView;
TextView name,price;
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_detail);
imageView = findViewById(R.id.product_detail_image);
name = findViewById(R.id.product_detail_name);
price = findViewById(R.id.product_detail_price);
212 | P a g e
190513116012
getSupportActionBar().setTitle(sName);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
name.setText(sName);
price.setText(sPrice);
imageView.setImageResource(iImage);
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{int id = item.getItemId(); if(id==android.R.id.home)
{onBackPre
ssed();
}
return super.onOptionsItemSelected(item);
}
}
ProductList.java
package internship.batch2;
213 | P a g e
190513116012
String name,price,unit;
int image;
214 | P a g e
190513116012
StatusFragment.java
package internship.batch2;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public StatusFragment() {
// Required empty public constructor
}
215 | P a g e
190513116012
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_status, container, false);
}
}
CallFragment.java
package internship.batch2;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public StatusFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
216 | P a g e
190513116012
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_status, container, false);
}
}
MessageActivity.java
package internship.batch2;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
TabLayout tabLayout;
ViewPager viewPager;
217 | P a g e
190513116012
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
getSupportActionBar().hide();
tabLayout = findViewById(R.id.message_tab);
viewPager = findViewById(R.id.message_pager);
tabLayout.post(new Runnable()
{@Override
public void run()
{ tabLayout.setupWithViewPager(viewPager);
}
});
viewPager.setAdapter(new MessageAdapter(getSupportFragmentManager()));
@Nullable
@Override
public CharSequence getPageTitle(int position)
{switch (position)
{ case 0:
218 | P a g e
190513116012
return "Chat";
case 1:
return "Status";
case 2:
return "Call";
case 3:
return "Chat";
case 4:
return "Status";
case 5:
return "Call";
}
return super.getPageTitle(position);
}
@NonNull
@Override
public Fragment getItem(int position)
{switch (position){
case 0 : return new ChatFragment();
case 1 : return new StatusFragment();
case 2 : return new CallFragment();
case 3 : return new ChatFragment();
case 4 : return new StatusFragment();
case 5 : return new CallFragment();
}
return null;
}
219 | P a g e
190513116012
@Override
public int getCount()
{return 6;
}
}
}
HomeActivity.xml
<androidx.appcompat.widget.SearchView
android:id="@+id/home_search"
android:background="@drawable/custom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:defaultQueryHint="Search Category/Product"
app:queryHint="Search Category/Product" />
220 | P a g e
190513116012
<!--<EditText
android:id="@+id/home_search"
style="@style/medium_16_edittext"
android:hint="Search Category/Product"
android:layout_margin="10dp"
android:padding="10dp"
android:background="@drawable/custom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>-->
<!--<AutoCompleteTextView
android:id="@+id/home_search"
android:hint="Search Category/Product"
android:padding="10dp"
android:background="@drawable/custom_border"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>-->
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Product" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_product_recyclerview"
android:layout_width="match_parent"
221 | P a g e
android:layout_height="wrap_content" />
<TextView
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Category" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
FragmentCall.xml
</FrameLayout>
222 | P a g e
190513116012
FragmentChat.xml
Fragment_status.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:background="@android:color/holo_red_light"
tools:context=".StatusFragment">
</FrameLayout>
Activity_product_detail.xml
223 | P a g e
190513116012
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".ProductDetailActivity">
<ImageView
android:id="@+id/product_detail_image"
android:layout_width="match_parent"
android:layout_height="250dp" />
<TextView
android:layout_marginTop="10dp"
android:id="@+id/product_detail_name"
style="@style/bold_20_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" />
<TextView
android:id="@+id/product_detail_price"
style="@style/bold_16_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" />
</LinearLayout>
Activity_product.xml
224 | P a g e
190513116012
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/product_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
225 | P a g e
190513116012
OUTPUT:
226 | P a g e
190513116012
227 | P a g e
190513116012 .
Chapter :- 4
Conclusion
On the whole, this internship was a useful experience. I have gained new knowledge, skills
and met many new people. I achieved several of my learning goals, however for some the
conditions did not permit. I got insight into professional practice. I learned the different
facets of working within a company. I experienced that financing, as in many organisations,
is an important factor for the progress of projects. Related to my study I learned more about
how to make Application in Android & flutter. There is still a lot to discover and to improve.
The methods used at the moment are still not standardized and a consistent method is in
development.
The internship was also good to find out what my strengths and weaknesses are. This
helped me to define what skills and knowledge I have to improve in the coming time. It
would be better that the knowledge level of the language is sufficient to contribute fully to
projects. when my degree is completed I think that I could start my working career.
However I could perform certain tasks in research better if I practice/know more then I
learn new thing in my subject. It would also be better if I can present and express myself
more confidently.
228 | P a g e
190513116012
References:
https://www.tutorialspoint.com/android/android_studio.htm
javatpoint.com/android-tutorial
229 | P a g e