title: How to call onclick on another activity?
body: <p>I just started development in android and got stuck with this idea </p>
  
  <p>I have created two activity one is the HomeActivity and other one is LoginActivity. I want to put minimal code in the HomeActivity and all other operations i want to put in another activity.</p>
  
  <p>My use-case is i have put an onclick event on HomeActivity and the onclick method implementation i have written in LoginActivity. But i am unable to call the LoginActivity onclick method implementation. Also, both HomeActivity and LoginActivity are having the same layout (activity_main.xml)</p>
  
  <p>The files are as follows:</p>
  
  <p>HomeActivity.java</p>
  
  <pre><code>public class HomeActivity extends Activity {
  
    private static String TAG = HomeActivity.class.getSimpleName();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
     }
  }
  </code></pre>
  
  <p>LoginActivity.java</p>
  
  <pre><code> public class LoginActivity extends Activity {
     private static String TAG = LoginActivity.class.getSimpleName();
  
     @Override
     protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
     }
  
    public void onLogin(View view){
       // some actions
     TextView loginText = (TextView)findViewById(R.id.login);
    }
  
    }
  </code></pre>
  
  <p>activity_home.xml</p>
  
  <pre><code>  &lt;TextView
      android:id="@+id/login"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"  
    /&gt;
    &lt;Button
       android:id="@+id/login_bt"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:onClick = "onLogin"
     /&gt;
  </code></pre>
  
  <p>Both HomeActivity and LoginActivity are using the same layout activity_home. Is it correct and possible to do this in android.
  and secondly if it's possible how to invoke onLogin on LoginActivity so that i can set the text to the TextView.</p>