ESTE ES EL XML
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.sfaci.agenda.MainActivity">
<item android:id="@+id/action_modificar"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="ifRoom|never"
android:icon="@drawable/ic_edit" />
<item android:id="@+id/action_GuardarDato"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="ifRoom|never"
android:icon="@drawable/ic_check" /> </menu>
ESTE EL JAVA
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
if (id == R.id.action_modificar){
if (tvNombreApellidos.isEnabled()&& ivFoto.isEnabled()&&
tvEmail.isEnabled()&& tvTelefonoFijo.isEnabled()&& tvTelefonoMovil.isEnabled()){
tvNombreApellidos.setEnabled(false);
ivFoto.setEnabled(false);
tvEmail.setEnabled(false);
tvTelefonoFijo.setEnabled(false);
tvTelefonoMovil.setEnabled(false);
}else{
tvNombreApellidos.setEnabled(true);
ivFoto.setEnabled(true);
tvEmail.setEnabled(true);
tvTelefonoFijo.setEnabled(true);
tvTelefonoMovil.setEnabled(true);
}
}
return super.onOptionsItemSelected(item);
}
menuItem.setIcon(R.drawable.icono);