title: Multiple activites for a layout in an login app
body: <p>Hey iam new to coding/java/android , please go easy on me </p>
  
  <p>I have added if else statement to login button ,</p>
  
  <pre><code>if(username = admin &amp;&amp; password = admin){ 
  then go to admin activity 
  }else if(username = manager &amp;&amp; password = manager){
  then go to manager activity 
  }else if(username = user &amp;&amp; password = user){
  then go to user activity
  }else{
  display text wrong password
  }
  </code></pre>
  
  <p>when in admin activity it calls for button add_user
  , in manager activity it calls for button order_items
  and in user activity it calls for button sales_report</p>
  
  <p>all the buttons are defined in activity_users_area.xml</p>
  
  <p><strong>Issue/Problem</strong></p>
  
  <p>Issue is when i login as admin in app it will show all the buttons displayed in layout file activity_users_area.xml
  same goes if i login as manager or user </p>
  
  <p>I want it to display only whats called in the respective Java class , how can i achieve this  </p>
  
  <p>Iam using same layout for Admin Manager and User because , In future i might add buttons which will be common for Admin User and Manager or Admin and Manger etc ...</p>
  
  <p>please don't suggest me to create database for admin , user and manager 
  looking for an option to solve without them </p>
  
  <p>This what my layout  looks like <strong>activity_users_area.xml</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".AdminAreaActivity"&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Add User"
          android:id="@+id/bAddUser"
          android:layout_alignParentTop="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Remove User"
          android:id="@+id/bRemoveUser"
          android:layout_below="@+id/bAddUser"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Change Stock"
          android:id="@+id/bChangeStock"
          android:layout_below="@+id/bRemoveUser"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Sales Report"
          android:id="@+id/bSalesReport"
          android:layout_below="@+id/bChangeStock"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Change Customer"
          android:id="@+id/bChangeCustomer"
          android:layout_below="@+id/bChangeStock"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Collection Report"
          android:id="@+id/bCollectionReport"
          android:layout_below="@+id/bSalesReport"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Stock Report"
          android:id="@+id/bStockReport"
          android:layout_below="@+id/bCollectionReport"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Pay Collect"
          android:id="@+id/bPayCollect"
          android:layout_below="@+id/bStockReport"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Item Sales"
          android:id="@+id/bItemSales"
          android:layout_below="@+id/bPayCollect"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Loan Collect"
          android:id="@+id/bLoanCollect"
          android:layout_below="@+id/bItemSales"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Order Items"
          android:id="@+id/bOrderItems"
          android:layout_below="@+id/bLoanCollect"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is my <strong>LoginActivity.java</strong></p>
  
  <pre><code>package online.klok.mobpos;
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class LoginActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
          final EditText etUsername = (EditText) findViewById(R.id.etUserName);
          final EditText etPassword = (EditText) findViewById(R.id.etPassword);
  
          final Button bLogin = (Button) findViewById(R.id.bLogin);
          final TextView registerLink = (TextView) findViewById(R.id.tvRegisterHere);
  
          registerLink.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent registerIntent = new Intent(LoginActivity.this, RegisterActivity.class);
                  LoginActivity.this.startActivity(registerIntent);
  
  
              }
          });
  
          bLogin.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  EditText username = (EditText) findViewById(R.id.etUserName);
                  EditText password = (EditText) findViewById(R.id.etPassword);
  
                  if (username.getText().toString().equals("admin") &amp;&amp; password.getText().toString().equals("admin")) {
                      Intent adminIntent = new Intent(LoginActivity.this, AdminAreaActivity.class);
                      LoginActivity.this.startActivity(adminIntent);
                  } else if(username.getText().toString().equals("manager") &amp;&amp; password.getText().toString().equals("manager")) {
                      Intent managerIntent = new Intent(LoginActivity.this, ManagerAreaActivity.class);
                      LoginActivity.this.startActivity(managerIntent);
                  }else if(username.getText().toString().equals("user") &amp;&amp; password.getText().toString().equals("user")) {
                      Intent userIntent = new Intent(LoginActivity.this, UserAreaActivity.class);
                      LoginActivity.this.startActivity(userIntent);
                  }else {
                      //wrong password
                      Toast.makeText(getApplicationContext(), "Wrong Credentials", Toast.LENGTH_SHORT).show();
                  }
              }
          });
  
      }
  }
  </code></pre>
  
  <p>Here is my <strong>AdminAreaActivity.java</strong></p>
  
  <pre><code>package online.klok.mobpos;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  
  public class AdminAreaActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_area);
  
          Button bAddUser = (Button) findViewById(R.id.bAddUser);
        bAddUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
  
            }
        });
    }
  }
  </code></pre>
  
  <p>Here is my <strong>ManagerAreaActivity.java</strong></p>
  
  <pre><code>package online.klok.mobpos;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  /**
   * Created by klok on 1/7/16.
   */
  public class ManagerAreaActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_area);
  
  
          final Button bOrderItems = (Button) findViewById(R.id.bOrderItems);
          bOrderItems.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p>Here is my <strong>UserAreaActivity.java</strong></p>
  
  <pre><code>package online.klok.mobpos;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  /**
   * Created by klok on 1/7/16.
   */
  public class UserAreaActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_area);
  
          final Button bSalesReport = (Button) findViewById(R.id.bSalesReport);
          bSalesReport.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
              }
          });
      }
  }
  </code></pre>