Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
- 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);
- }
- }
Add Comment
Please, Sign In to add comment