0% found this document useful (0 votes)
9 views10 pages

Demo App

The document provides a detailed implementation plan for building a simple tour and tourism app in Java using Android Studio. It outlines the app structure, including key activities such as LoginActivity and HomeActivity, and includes code snippets for each component. Additionally, it emphasizes the need for customization and the implementation of actual login functionality using a backend service.

Uploaded by

gzore7941
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Demo App

The document provides a detailed implementation plan for building a simple tour and tourism app in Java using Android Studio. It outlines the app structure, including key activities such as LoginActivity and HomeActivity, and includes code snippets for each component. Additionally, it emphasizes the need for customization and the implementation of actual login functionality using a backend service.

Uploaded by

gzore7941
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Here’s how you can build a simple tour and tourism app in Java using Android

Studio (2024 version). Below is a detailed implementation plan and code


snippets.

### App Structure Overview:

1. **LoginActivity.java** - Handles login and registration for new and old


users.

2. **HomeActivity.java** - The main dashboard after login.

3. **Menu Drawer** - Contains options like Settings, History, Contact Us,


About, Feedback, and Payment.

4. **Individual Activities** - Each menu option leads to its own activity (e.g.,
SettingsActivity.java).

### Step-by-Step Implementation:

#### 1. **LoginActivity.java**

This activity handles user login and registration.

```java

Package com.example.tourapp;

Import android.content.Intent;

Import android.os.Bundle;

Import android.view.View;

Import android.widget.Button;

Import androidx.appcompat.app.AppCompatActivity;

Public class LoginActivity extends AppCompatActivity {


@Override

Protected void onCreate(Bundle savedInstanceState) {

Super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login);

Button loginButton = findViewById(R.id.btn_login);

loginButton.setOnClickListener(new View.OnClickListener() {

@Override

Public void onClick(View v) {

// Assume validation is successful and navigate to the home screen

Intent intent = new Intent(LoginActivity.this, HomeActivity.class);

startActivity(intent);

finish(); // Close the login activity

});

Button registerButton = findViewById(R.id.btn_register);

registerButton.setOnClickListener(new View.OnClickListener() {

@Override

Public void onClick(View v) {

// Navigate to the registration screen

Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);

startActivity(intent);

});

}
}

```

#### 2. **HomeActivity.java**

This activity serves as the main dashboard after login and hosts the
navigation drawer.

```java

Package com.example.tourapp;

Import android.content.Intent;

Import android.os.Bundle;

Import androidx.appcompat.app.AppCompatActivity;

Import androidx.drawerlayout.widget.DrawerLayout;

Import android.view.MenuItem;

Import com.google.android.material.navigation.NavigationView;

Public class HomeActivity extends AppCompatActivity {

Private DrawerLayout drawerLayout;

Private NavigationView navigationView;

@Override

Protected void onCreate(Bundle savedInstanceState) {

Super.onCreate(savedInstanceState);

setContentView(R.layout.activity_home);
drawerLayout = findViewById(R.id.drawer_layout);

navigationView = findViewById(R.id.nav_view);

navigationView.setNavigationItemSelectedListener(new
NavigationView.OnNavigationItemSelectedListener() {

@Override

Public boolean onNavigationItemSelected(MenuItem item) {

Switch (item.getItemId()) {

Case R.id.nav_settings:

startActivity(new Intent(HomeActivity.this,
SettingsActivity.class));

break;

case R.id.nav_history:

startActivity(new Intent(HomeActivity.this,
HistoryActivity.class));

break;

case R.id.nav_contact:

startActivity(new Intent(HomeActivity.this,
ContactUsActivity.class));

break;

case R.id.nav_about:

startActivity(new Intent(HomeActivity.this,
AboutActivity.class));

break;

case R.id.nav_feedback:

startActivity(new Intent(HomeActivity.this,
FeedbackActivity.class));

break;

case R.id.nav_payment:
startActivity(new Intent(HomeActivity.this,
PaymentActivity.class));

break;

drawerLayout.closeDrawers(); // Close the drawer after selection

return true;

});

```

#### 3. **Drawer Menu Layout (res/menu/drawer_menu.xml)**

This XML file defines the drawer items.

```xml

<menu xmlns:android=http://schemas.android.com/apk/res/android>

<item

Android:id=”@+id/nav_settings”

Android:title=”Settings” />

<item

Android:id=”@+id/nav_history”

Android:title=”History” />

<item

Android:id=”@+id/nav_contact”

Android:title=”Contact Us” />

<item
Android:id=”@+id/nav_about”

Android:title=”About Us” />

<item

Android:id=”@+id/nav_feedback”

Android:title=”Feedback” />

<item

Android:id=”@+id/nav_payment”

Android:title=”Payment” />

</menu>

```

#### 4. **activity_home.xml (Home Layout with Drawer)**

This layout defines the drawer structure.

```xml

<androidx.drawerlayout.widget.DrawerLayout

Xmlns:android=http://schemas.android.com/apk/res/android

Android:id=”@+id/drawer_layout”

Android:layout_width=”match_parent”

Android:layout_height=”match_parent”>

<!—Main content goes here 

<FrameLayout

Android:layout_width=”match_parent”

Android:layout_height=”match_parent”>

<!—Add your home screen content here 

</FrameLayout>
<com.google.android.material.navigation.NavigationView

Android:id=”@+id/nav_view”

Android:layout_width=”wrap_content”

Android:layout_height=”match_parent”

Android:layout_gravity=”start”

App:menu=”@menu/drawer_menu” />

</androidx.drawerlayout.widget.DrawerLayout>

```

#### 5. **Additional Activities for Drawer Items**

Each menu option has its own activity. For example, here’s the
`SettingsActivity.java`:

```java

Package com.example.tourapp;

Import android.os.Bundle;

Import androidx.appcompat.app.AppCompatActivity;

Public class SettingsActivity extends AppCompatActivity {

@Override

Protected void onCreate(Bundle savedInstanceState) {

Super.onCreate(savedInstanceState);

setContentView(R.layout.activity_settings);

}
```

You’ll have similar Java classes for **HistoryActivity**, **ContactUsActivity**,


**AboutActivity**, **FeedbackActivity**, and **PaymentActivity**.

#### 6. **activity_settings.xml (Example of a Settings Layout)**

```xml

<LinearLayout

Xmlns:android=http://schemas.android.com/apk/res/android

Android:layout_width=”match_parent”

Android:layout_height=”match_parent”

Android:orientation=”vertical”

Android:padding=”16dp”>

<TextView

Android:layout_width=”wrap_content”

Android:layout_height=”wrap_content”

Android:text=”Settings Page”

Android:textSize=”20sp”

Android:textStyle=”bold” />

<!—Add more settings options here 

</LinearLayout>

```

#### 7. **AndroidManifest.xml Configuration**

Ensure all activities are declared in the manifest:


```xml

<application

…> <activity android:name=”.LoginActivity” />

<activity android:name=”.HomeActivity” />

<activity android:name=”.SettingsActivity” />

<activity android:name=”.HistoryActivity” />

<activity android:name=”.ContactUsActivity” />

<activity android:name=”.AboutActivity” />

<activity android:name=”.FeedbackActivity” />

<activity android:name=”.PaymentActivity” />

<activity android:name=”.RegisterActivity” />

<activity android:name=”.MainActivity”>

<intent-filter>

<action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />

</intent-filter>

</activity>

</application>

```

### Final Notes:

- Customize each layout and activity based on your specific app’s needs.

- Implement actual login functionality using Firebase or any other backend


service.

- Improve UI using Material Design components for a more professional look.


This project structure is a basic foundation that you can expand based on
your requirements.

You might also like