我是新手,我无法解决主题问题。我使用Android Studio,我有标准的'hello world'应用程序我试图在其上使用Theme.Holo,所以我在我的清单文件中将minSdkVersion
设置为"11"
(我知道它只能在11及以上使用)。然后在styles.XML中,我将AppTheme更改为android:Theme.Holo
。我可以在我的预览中看到主题已经正确更改但是当我在手机上运行我的应用程序(Android 4.2.2 API 17)时,我收到错误'申请已被停止'当我回到标准Theme.AppCompat.Light.DarkActionBar
时,应用程序正常启动。
我还试图通过application
android:theme="@android:style/Theme.Holo", but then it is not displayed in the preview and also is being stopped when trying to run on the phone.
的清单文件中应用Theme.Holo
我真的一直在寻找答案而且开始非常令人沮丧,有人可以帮我解决这个问题吗?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.actiobar_app" >
<uses-sdk android:minSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
...
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo">
</style>
</resources>
//主要活动
package com.mycompany.actiobar_app;
import android.app.ActionBar;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@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;
}
return super.onOptionsItemSelected(item);
}
}
logcat的
02-03 20:47:10.546 24023-24023/? E/SharedPreferenceProvider﹕ onCreate
02-03 20:47:11.226 598-24036/? E/android.os.Debug﹕ !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error
02-03 20:47:12.500 24082-24082/? E/SPPClientService﹕ ============PushLog. commonIsShipBuild. stop!
02-03 20:47:12.500 24082-24082/? E/SPPClientService﹕ [PushClientApplication] Push log off : This is Ship build version
02-03 20:47:12.789 116-9832/? E/AudioPolicyService﹕ getParamFromPolicy : enter , keys = situation=1;device=0
02-03 20:47:12.796 116-9832/? E/audio_policy_mrvl﹕ mrvl_ap_getParamFromPolicy: situation=1;device=0
02-03 20:47:12.882 598-649/? E/ViewRootImpl﹕ sendUserActionEvent() mView == null
02-03 20:47:12.882 598-609/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
02-03 20:47:17.664 24206-24229/? E/ActivityThread﹕ Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
02-03 20:47:18.117 26884-26884/? E/AuthorizationBluetoothService﹕ Proximity feature is not enabled.
02-03 20:47:30.312 598-1004/? E/Watchdog﹕ !@Sync 5949
02-03 20:47:42.750 598-664/? E/lights﹕ write_int failed to open -1
02-03 20:47:47.914 598-649/? E/NotificationService﹕ Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null])
02-03 20:47:47.976 598-649/? E/NotificationService﹕ Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null])
02-03 20:47:48.000 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.000 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.000 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.000 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.046 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.046 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.046 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.046 598-647/? E/LSO﹕ LSO Service is not yet ready!!!
02-03 20:47:48.093 598-647/? E/SoundPool﹕ error loading /system/media/audio/ui/lens_flare_tap.ogg
02-03 20:47:48.093 598-647/? E/SoundPool﹕ error loading /system/media/audio/ui/lens_flare_unlock.ogg
02-03 20:47:48.210 598-649/? E/NotificationService﹕ Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null])
02-03 20:48:00.312 598-1004/? E/Watchdog﹕ !@Sync 5950
02-03 20:48:30.312 598-1004/? E/Watchdog﹕ !@Sync 5951
02-03 20:49:00.320 598-1004/? E/Watchdog﹕ !@Sync 5952
02-03 20:49:06.390 24306-24306/? E/Samsung TTS﹕ onIsLanguageAvailable() - lang : pol, country : POL, variant : , iResult : -2
02-03 20:49:06.390 24306-24306/? E/﹕ Samsung TTS Engine - initialize() : Samsung TTS Engine (released - 201302151)
02-03 20:49:06.390 24306-24306/? E/﹕ Samsung TTS Engine - initialize() : ro.product.manufacturer - samsung
02-03 20:49:06.625 24306-24320/? E/Samsung TTS﹕ onIsLanguageAvailable() - lang : eng, country : USA, variant : , iResult : 1
02-03 20:49:06.625 24306-24320/? E/Samsung TTS﹕ onLoadLanguage() - LANG_COUNTRY_AVAILABLE
02-03 20:49:06.625 24306-24320/? E/Samsung TTS﹕ onLoadLanguage() - lang : eng, country : USA, variant : f01
02-03 20:49:30.320 598-1004/? E/Watchdog﹕ !@Sync 5953
02-03 20:50:00.320 598-1004/? E/Watchdog﹕ !@Sync 5954
02-03 20:50:30.320 598-1004/? E/Watchdog﹕ !@Sync 5955
02-03 20:50:40.960 2639-2639/? E/SPPClientService﹕ [[PushClientService]] onStartCommand. F:false, D:false, E:false, T:false, S:false, R:false
02-03 20:51:00.320 598-1004/? E/Watchdog﹕ !@Sync 5956
02-03 20:51:30.320 598-1004/? E/Watchdog﹕ !@Sync 5957
02-03 20:51:41.320 20425-20463/? E/PlayEventLogger﹕ Upload failed class java.net.UnknownHostException(Unable to resolve host "play.googleapis.com": No address associated with hostname)
02-03 20:52:00.328 598-1004/? E/Watchdog﹕ !@Sync 5958
02-03 20:52:30.328 598-1004/? E/Watchdog﹕ !@Sync 5959
02-03 20:53:00.328 598-1004/? E/Watchdog﹕ !@Sync 5960
02-03 20:53:30.328 598-1004/? E/Watchdog﹕ !@Sync 5961
02-03 20:54:00.328 598-1004/? E/Watchdog﹕ !@Sync 5962
02-03 20:54:30.328 598-1004/? E/Watchdog﹕ !@Sync 5963
02-03 20:55:00.328 598-1004/? E/Watchdog﹕ !@Sync 5964
02-03 20:55:30.335 598-1004/? E/Watchdog﹕ !@Sync 5965
02-03 20:56:00.335 598-1004/? E/Watchdog﹕ !@Sync 5966
答案 0 :(得分:0)
我的猜测是,Activity
可能会延长ActionBarActivity
,这意味着您拥有来使用AppCompat
主题(或后代)。