Good morning everyone I develop an app in Android studio but I have a problem opening an activity and that is when I touch a button, it is supposed to send me to another screen however when I do that, the app closes, I followed the steps I've seen on YouTube but it does not work. ..
this is the main activity that calls another one called searchtabs
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button btnLogin;
EditText txtUser, txtPass;
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),searchtabs.class);
startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtUser = (EditText) findViewById(R.id.txtUser);
txtPass = (EditText) findViewById(R.id.txtPass);
btnLogin = (Button) findViewById(R.id.btnInicio);
btnLogin.setOnClickListener(this);
}
}
and this is the activity that should be executed
public class searchtabs extends AppCompatActivity {
private TabLayout tabLayout;
private AppBarLayout appBarLayout;
private ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchtabs);
tabLayout = (TabLayout) findViewById(R.id.tablayout_id);
appBarLayout = (AppBarLayout) findViewById(R.id.appbarid);
viewPager = (ViewPager) findViewById(R.id.viewpager_id);
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
// Añadiendo fragments
adapter.AddFragment(new FragmentBuscar(), "Buscar");
adapter.AddFragment(new FragmentPromo(), "Promociones");
adapter.AddFragment(new FragmentPerfil(), "Perfil");
// adaptador
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
}
}
If I forget something, I thank you, thank you.