Hello.
Download Nairobi West APK final here
Once downloaded, check your downloads folder and install the apk.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>here
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nairobiwest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="NAIROBI WEST HOSPITAL"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NAIROBIWEST">
<activity android:name=".splashscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".home" />
<activity android:name=".MainActivity"/>
</application>
</manifest>
home.java
package com.example.nairobiwest;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.Calendar;
public class home extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
RadioButton radioButton;
RadioGroup radioGroup;
Spinner spinner1,spinner2;
EditText date_edit; //for date edit text
DatePickerDialog datePickerDialog;
EditText required_name;
Button button_submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//remove title and action bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
setContentView(R.layout.activity_home);
spinner1=findViewById(R.id.spinner_clinic);
spinner2=findViewById(R.id.spinnertime);
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this,R.array.clinic, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter);
spinner1.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter1=ArrayAdapter.createFromResource(this,R.array.time, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(adapter1);
spinner2.setOnItemSelectedListener(this);
//Date//Get view by id for the date_edit variable which will be datefield id
date_edit=findViewById(R.id.datefield);
//Create an Onclick listener for the edit text field i.e date_field
date_edit.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View v) {//Create a calender variable then get calender using the system locale and time zone
Calendar calendar=Calendar.getInstance();
int year=calendar.get(Calendar.YEAR); //year variable
int month=calendar.get(Calendar.MONTH);//month variable
int day=calendar.get(Calendar.DAY_OF_MONTH);//day variable/*show a datePickerDialog on the home activity/same screen then set the selected date to
the select date field or date_edit variable*/
datePickerDialog=new DatePickerDialog(home.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {date_edit.setText(day+"/"+(month+1)+"/"+year);//setting the date we add 1 to month since they start at 0-strings
}
},year,month,day);
datePickerDialog.show(); //show the datepicker Dialog
}
});
}
//back arrow at the top
public void goBack(View v){
Intent intent=new Intent(home.this,MainActivity.class);
startActivity(intent);
}
//spinners
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String text=parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(),text,Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
//submit button on click
public void submitCheck(View v){
Toast.makeText(this, "Your appointment has been submitted", Toast.LENGTH_LONG).show();
}
}
MainActivity.java
package com.example.nairobiwest;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//remove title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
button=findViewById(R.id.btn_select_service);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,home.class);
startActivity(intent);
}
});
}
}
splashscreen.java
package com.example.nairobiwest;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import java.util.Timer;
import java.util.TimerTask;
public class splashscreen extends AppCompatActivity {
private ProgressBar progressBar; //progress bar (loading progress)
private Timer timer; //for progress bar
private int i=0; //initial state of progress bar
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//remove title and action bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
setContentView(R.layout.activity_splashscreen);
//progress bar
progressBar=findViewById(R.id.progressBar);
timer=new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (i<100){
runOnUiThread(new Runnable() {
@Override
public void run() {
}
});progressBar.setProgress(i);
i++;
}else {
timer.cancel();
Intent intent=new Intent(splashscreen.this,MainActivity.class); //open a new activity if i<=100
startActivity(intent);
finish();
}
}
},0,50);
}
}
ALL PROJECT FILES SCREENSHOT
activity_home.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=".home"
android:orientation="vertical"
android:background="@color/teal_200">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/backj"
android:padding="3dp"
android:layout_marginLeft="7dp"
android:onClick="goBack"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Book an appointment"
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif-medium"
android:textColor="@color/black"
android:textSize="18dp"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#808080"/>
<TextView
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="10dp"
android:text="NAIROBI WEST HOSPITAL"
android:textSize="30dp"
android:fontFamily="sans-serif-condensed"
android:textColor="#000"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:orientation="vertical"
android:padding="2dp">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#D3D3D3"
android:hint="Your name *"
android:textColor="@color/white"
android:id="@+id/name_field"/>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#D3D3D3"
android:hint="Location"
android:textColor="@color/white"
android:id="@+id/location_field"
android:layout_marginTop="10dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#D3D3D3"
android:hint="Phone number"
android:layout_marginTop="10dp"
android:inputType="number"
android:textColor="@color/white"
android:id="@+id/phone_field"/>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#D3D3D3"
android:hint="Email"
android:id="@+id/email_field"
android:textColor="@color/white"
android:layout_marginTop="10dp"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/preferredcommunication"
android:layout_marginTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/preftext"
android:text="Preferred mode of communication"
android:textStyle="bold"
android:textColor="@color/black"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="Phone"
android:textColor="@color/black"
android:id="@+id/phone_rd"
android:textSize="14dp"
android:background="#D3D3D3"
android:layout_marginTop="10dp"/>
<RadioButton
android:id="@+id/email_rd"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="Email"
android:background="#D3D3D3"
android:textColor="@color/black"
android:textSize="14dp" />
</RadioGroup>
<Spinner
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/spinner_clinic"
android:backgroundTint="@color/black"
android:layout_marginTop="10dp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Select Date"
android:background="#D3D3D3"
android:layout_marginTop="10dp"
android:textColor="@color/white"
android:id="@+id/datefield"
android:inputType="datetime"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/spinnertime"
android:backgroundTint="@color/black"
android:layout_marginTop="10dp"/>
<Button
android:id="@+id/btnsubmit"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/dark_green"
android:text="SUBMIT"
android:onClick="submitCheck"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
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"
android:background="@color/teal_700">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginTop="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/hospitalimg"/>
<Button
android:id="@+id/btn_select_service"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Book appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
android:textSize="20sp"/>
<TextView
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="The Nairobi West Hospital"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="1.0"
android:textColor="@color/white"
android:textStyle="italic"/>
</androidx.constraintlayout.widget.ConstraintLayout>
activity_splashscreen.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=".splashscreen"
android:background="@color/white">
<ImageView
android:id="@+id/imageView2"
android:layout_width="335dp"
android:layout_height="251dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.216"
app:srcCompat="@drawable/nairobiwestlogo" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2"
app:layout_constraintVertical_bias="0.124"
android:scaleY="3"
android:progressBackgroundTint="@color/design_default_color_primary_dark"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
strings.xml
<resources>
<string name="app_name">NAIROBIWEST</string>
<string-array name="clinic">
<item>Select Clinic</item>
<item>Optician</item>
<item>Dentist</item>
<item>Radiologists</item>
<item>Cardiologist</item>
<item>Dermatologist</item>
</string-array>
<string-array name="time">
<item>Select time</item>
<item>8AM</item>
<item>9AM</item>
<item>10AM</item>
<item>11AM</item>
<item>12PM</item>
</string-array>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="dark_green">#006400</color>
</resources>
Comments
Post a Comment