Widget Recent Post No.

header ads

Create Login And Registration Screen In Android Using Firebase | App Development


Step 1 Home.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:orientation="vertical"
    tools:context=".HomeActivity">

    <TextView
        android:textColor="#000"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:layout_marginLeft="120dp"
        android:textSize="60dp"
        android:text="HOME"/>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id = "@+id/bottom_navigation"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_alignParentBottom = "true"
        app:itemBackground = "@color/colorPrimary"
        app:itemIconTint="#000"
        app:itemTextColor="#000"
        app:menu = "@menu/bottom_navigation"/>

</RelativeLayout>

Step 2 Home.java
package in.learncodewithrk.appsigninsignupcreateprofile;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Toast;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        BottomNavigationView bottomNavigationView = (BottomNavigationView)
                findViewById(R.id.bottom_navigation);

        bottomNavigationView.setOnNavigationItemSelectedListener(
                new BottomNavigationView.OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                        switch (item.getItemId()) {
                            case R.id.service_ng:
                                Intent service_ng = new Intent(HomeActivity.this, service.class);
                                startActivity(service_ng);
                                break;
                            case R.id.action_home:
                                Intent action_home = new Intent(HomeActivity.this, nghome_page.class);
                                startActivity(action_home);
                                break;
                            case R.id.action_profile:
                                Intent inentProfile = new Intent(HomeActivity.this, ProfileActivity.class);
                                startActivity(inentProfile);
                                break;
                        }
                        return true;
                    }
                });
    }
}



 

Post a Comment

0 Comments