It turns out that I have a button that performs an action with an if but it turns out that if it does not enter that if I need to run a method of an android class that are the ones that put the menu in the action bar:
btnBuscar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TextUtils.isEmpty(primerNombre.getText().toString().trim())){
customToadError(getApplicationContext(),"Debe ingresar al menos un criterio de búsqueda");
}else{
// aqui deberian ejecutarse los metodos de sobreescritos que pondrian una opcion
}
}
});
these are the methods about writing:
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.add, menu);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_agregar) {
Intent i=new Intent(ListSrActivity.this, NuevoSRActivity.class);
startActivity(i);
}
return super.onOptionsItemSelected(item);
}