Android Tutorial #5 - Toolbar - Action-bar - Menu @SafaaAlaa
Android Tutorial #5 - Toolbar - Action-bar - Menu  @SafaaAlaa
Uploaded July 2018 | Updated September 2026, 2 weeks ago
Toolbar or Action-bar or Menu, is quite useful feature you have to take benefit from it, by creating action or menu items to do some action in your app, or you can use it for navigation and for displaying logo or your app brand.
so, in this video you'll learn about toolbar...
and at the end of this video you'll face a small issue in updating the parent activity, I've already explained that in this tutorial:
youtu.be/geql_wwXIhw

but, if you can't solve it here is the solution:
ListOfUsers.java:


@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.new_user:
Intent intent = new Intent(this, NewUser.class);
startActivityForResult(intent,2);
return true;
default:
return super.onOptionsItemSelected(item);

}

}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
if(requestCode == 1){
if(data!=null){
//mUsersAdapter.notifyDataSetChanged();
String action = data.getStringExtra("action");
if(action.equals("update")){
mUsersAdapter.notifyItemChanged(mPosition);
}else if(action.equals("delete")){
mUsersAdapter.notifyItemRemoved(mPosition);
}
}
}else if(requestCode == 2){
mUsersAdapter.notifyItemInserted(mUsers.size());
}
}
}

========================================
NewUser.java:

mAdd_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(RESULT_OK,null);
User user = new User();
user.setFirstname(mFirstname_editTxt.getText().toString());
user.setEmail(mEmail_editTxt.getText().toString());

UsersBase.get().newUser(user);
Toast.makeText(NewUser.this,"New user has been added to the list",
Toast.LENGTH_LONG).show();
mFirstname_editTxt.setText("");
mEmail_editTxt.setText("");
}
});
Android Tutorial #5 - Toolbar - Action-bar - MenuHow to Transfer Files From PC to iPhone - iPad - iPod (Without iTunes)!How to Fix Verification Required issue when installing Free Apps from the App Store on iPhone /iPadHow to Create SnapChat account from Computer(Laptop/PC)PART #1: Registration and Login System Tutorial Using PHP and MYSQLHow to quickly make a Laravel 5.2 app with Registration, Login, Password Reset and DashboardHow To Fix Error 0xc000021a - Your PC ran into a problem and needs to restartOBS Fix Pixelated Blurry Blocky Recordinglearn ajax : episode #3: How to make Asynchronous XHR Request with JavaScript and AJAXTop 5 Best FREE VPN 2016How to Connect XBox One S Controller to PC / Laptophow to play clash of clans coc on pc for free
Safaa Al-Hayali (Safaa Alaa) |

Android Tutorial #5 - Toolbar - Action-bar - Menu

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER