この下のコードのsetContentViewにエラーがでます。
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
どうすればいいのでしょうか?
xml
1<?xml version="1.0" encoding="utf-8"?> 2<!-- Copyright (C) 2016 The Android Open Source Project 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15--> 16 17<resources xmlns:android="http://schemas.android.com/apk/res/android"> 18 19 <style name="PlayerTheme" parent="android:Theme.Holo"> 20 <item name="android:windowNoTitle">true</item> 21 <item name="android:windowBackground">@android:color/black</item> 22 </style> 23 24</resources> 25
xml
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.google.android.exoplayer2.demo.CheckGpsActivity"> 8 9</LinearLayout> 10
java
1 public class CheckGpsActivity extends AppCompatActivity { 2 3 private final int REQUEST_PERMISSION = 1000; 4 5 @Override 6 protected void onCreate(Bundle savedInstanceState) { 7 super.onCreate(savedInstanceState); 8 setContentView(R.layout.activity_checkgps); 9 10 // Android 6, API 23以上でパーミッシンの確認 11 if(Build.VERSION.SDK_INT >= 23){ 12 checkPermission(); 13 } 14 else{ 15 locationActivity(); 16 } 17 } 18
java
1E/AndroidRuntime: FATAL EXCEPTION: main 2 Process: com.google.android.exoplayer2.demo, PID: 23581 3 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.exoplayer2.demo/com.google.android.exoplayer2.demo.CheckGpsActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 4 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) 5 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 6 at android.app.ActivityThread.-wrap12(ActivityThread.java) 7 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 8 at android.os.Handler.dispatchMessage(Handler.java:102) 9 at android.os.Looper.loop(Looper.java:154) 10 at android.app.ActivityThread.main(ActivityThread.java:6119) 11 at java.lang.reflect.Method.invoke(Native Method) 12 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 13 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 14 Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 15 at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:351) 16 at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:320) 17 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281) 18 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 19 at com.google.android.exoplayer2.demo.CheckGpsActivity.onCreate(CheckGpsActivity.java:23) 20 at android.app.Activity.performCreate(Activity.java:6679) 21 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 22 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) 23 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 24 at android.app.ActivityThread.-wrap12(ActivityThread.java) 25 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 26 at android.os.Handler.dispatchMessage(Handler.java:102) 27 at android.os.Looper.loop(Looper.java:154) 28 at android.app.ActivityThread.main(ActivityThread.java:6119) 29 at java.lang.reflect.Method.invoke(Native Method) 30 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 31 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
回答1件
あなたの回答
tips
プレビュー