2
I’m using the default menu Navigation Drawer
and complemented the method that already comes in the project to open my activities(Atividades)
. I have already created the classes and called each of them as image below, but when I click on a menu item, and it does not change windows.
and here’s one of my classes:
public class SecondActivity extends AppCompatActivity {
private Button share;
private Toolbar mToolbar;
private Toolbar mToolbarBottom;
private Button action_settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
mToolbarBottom = (Toolbar) findViewById(R.id.inc_tb_bottom);
mToolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent it = null;
switch(menuItem.getItemId()){
case R.id.action_facebook:
it = new Intent(Intent.ACTION_VIEW);
it.setData(Uri.parse("https://www.facebook.com/PrefeituraMunicipalDeJaguaruana"));
break;
case R.id.action_youtube:
it = new Intent(Intent.ACTION_VIEW);
it.setData(Uri.parse("http://www.jaguaruana.ce.gov.br/"));
}
startActivity(it);
return true;
}
});
mToolbarBottom.inflateMenu(R.menu.menu_bottom);
/*mToolbarBottom.findViewById(R.id.iv_settings).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SecondActivity.this, "Settings pressed", Toast.LENGTH_SHORT).show();
}*/
}
@Override
protected void onResume() {
super.onResume();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
mToolbar.setBackgroundResource(R.drawable.toolbar_rounded_corners);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_second, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == android.R.id.home){
finish();
}
return true;
}
try to change to
Intent intent = new Intent(this, MainActivity.class); startActivity(intent);
– user28366