Reputation: 19
I'm trying to change the "Navigation Up" icon with a drawable image(in eclipse) but all I can do now is change the logo(ic_launcher) instead. I uploaded an image here is the link for image to circling the icon which I want to change. I tried to change it by using "@styles" but was unsuccessful. Thanks in advance for any help. Here is my code:
public class SecondActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.second_layout);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case android.R.id.home:
Intent intent = new Intent(this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
return true;
}
}
Upvotes: 0
Views: 1044
Reputation: 11873
You need to use a custom theme for your activity in the manifest. The style should look like this,
<style name="Theme.MyTheme" parent="android:Theme.Holo">
<item name="android:homeAsUpIndicator">@drawable/my_custom_indicator</item>
</style>
finally set the style in the manifest,
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
You can also achieve this programatically,
Without support library
ActionBar().setHomeAsUpIndicator(R.drawable.ic_yourindicator);
With support library
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_yourindicator);
Upvotes: 2