截至指示灯不露面 [英] Up indicator does not show up
问题描述
目前,我正在试图启用向上导航我的Android应用程序。
要做到这一点,我也跟着教程和实施必要的code到我的活动:
I'm currently trying to enable up navigation in my Android app. To do so, I followed the tutorial and implemented the necessary code into my activity:
package de.ntraum.arcon;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.MenuItem;
public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setHomeButtonEnabled(true);
addPreferencesFromResource(R.xml.settings);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
startActivity(new Intent(SettingsActivity.this, MainActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
如果有关,这里的的AndroidManifest.xml
和 styles.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ntraum.arcon"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Light" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings" >
<intent-filter>
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
</application>
</manifest>
styles.xml
<resources>
<style name="Light" parent="android:Theme.Holo.Light.DarkActionBar" />
<style name="Dark" parent="android:Theme.Holo" />
</resources>
问题
问题是,在访问活动时,在操作栏中向上的指标缺失。尽管如此,导航实际上是工作(它把我带回到了 MainActivity.class
),它只是小指示灯不正确显示。
Issue
The thing is, when accessing the activity, the up indicator in the action bar is missing. Nevertheless, the navigation is actually working (it takes me back to the MainActivity.class
), it's just the small indicator that does not show up correctly.
我测试过我自己的设备上,在模拟器至今。
I've tested it on my own device and in the emulator so far.
推荐答案
的文档说叫<一个href=\"http://developer.android.com/reference/android/app/ActionBar.html#setDisplayHomeAsUpEnabled%28boolean%29\">setDisplayHomeAsUpEnabled(true)在你的动作条。你实际上调用不同的方法, setHomeButtonEnabled
,所以尽量从文档添加通话。
The docs say to call setDisplayHomeAsUpEnabled(true) on your action bar. You're actually calling a different method, setHomeButtonEnabled
, so try adding the call from the docs.
这篇关于截至指示灯不露面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!