public class ItemAdapter extends RecyclerView.Adapter<ItemViewHolder> {
private List<Item> mItemList = new ArrayList<>();
private List<Item> mItemsCopy = new ArrayList<>();
/**
* Фильтрует отображаемые пользователю данные при вводе текста в поиск
*
* @param query the query
*/
void filter(String query) {
mItemList.clear();
if (query.isEmpty()) {
mItemList.addAll(mItemsCopy);
} else {
query = query.toLowerCase();
for (Item item : mItemsCopy) {
if (item.getUserName().toLowerCase().contains(query)) {
mItemList.add(item);
}
}
}
notifyDataSetChanged();
}
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("Поделиться");
}
}
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.