Last active
January 25, 2023 13:16
-
-
Save hello2pal/4548094 to your computer and use it in GitHub Desktop.
How to Navigate from One Activity to Another Activity in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
public class MainActivity extends Activity { | |
private Button button; // | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
/* | |
*Each activity must have a corresponding layout XML file | |
*/ | |
setContentView(R.layout.activity_main);// activity_main is corresponding XML file | |
/* | |
* Initializing button XML button id. findViewById is a method which | |
* helps to initialize with particular id. btn_go_to_another_activity is | |
* a button name which I have given in XML file | |
*/ | |
button = (Button) findViewById(R.id.btn_go_to_another_activity); | |
button.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// TODO Auto-generated method stub | |
/* | |
* Intent is just like glue which helps to navigate one activity | |
* to another. | |
*/Intent intent = new Intent(MainActivity.this, | |
AnotherActivity.class); | |
startActivity(intent); // startActivity allow you to move | |
} | |
}); | |
} | |
} |
TextView
textView
=
(TextView)
findViewById(R.id.homeText);
textView.setOnClickListener(new
View.OnContextClickListener()
{
@Override
public void onclick (View v) {
Intent intent = new Intent(RegisterActivity.this, ForgetPassword.class);
startActivity(intent);
}
`});```
For beginners I recommend this post... https://androidride.com/how-to-move-from-one-activity-to-another-in-android/
Noble Transfer is an online private transfer and shuttle services offering reliable, luxury and comfortable transfer services from & to the airport and tourist resorts.limousine service zurich
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can anyone please help to find out error after login succesfully they dont navigate to another activity
package com.Dimple.flashchatnewfirebase;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class LoginActivity extends AppCompatActivity {
private void attemptLogin() {
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
}