For some reason, when testing on my Motorola Xoom with Ice Cream Sandwich, the App Icon in the Action Bar is not clickable, even though I have implemented an event handler. This only occurs after changing the targetSdkVersion to 15. If it is 13 it is still clickable, even on ICS. Why is this happening and how can I make it clickable like a button? I searched the documentation and couldn't find anything.
Thank you.
UPDATE: Here is my code:
AndroidManifest.xml:
...
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@style/android:Theme.Holo.Light">
...
BaseActivity.java (my activities all inherit from this class:
...
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// app icon in action bar clicked; go home
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
...
I found it in the documentation at http://developer.android.com/guide/topics/ui/actionbar.html:
Note: If you're using the icon to navigate to the home activity, beware that beginning with Android 4.0 (API level 14), you must explicitly enable the icon as an action item by calling setHomeButtonEnabled(true) (in previous versions, the icon was enabled as an action item by default).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With