Android
- 5 ответов
- 0 вопросов
5
Вклад в тег
startActivity(new Intent(FirstActivity.this, SecondActivity.class));
finish();
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
This launch mode can also be used to good effect in conjunction with FLAG_ACTIVITY_NEW_TASK: if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state. This is especially useful, for example, when launching an activity from the notification manager.
Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(Menu.NONE, nav_share, Menu.NONE, "Share");
super.onCreateOptionsMenu(menu, inflater);
}
public class MyFragment extends Fragment {
private Menu menu;
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
this.menu = menu;
super.onCreateOptionsMenu(menu, inflater);
}
private void updateTitle () {
MenuItem shareItem = menu.findItem(R.id.share);
shareItem.setTitle("Поделиться");
}
}