16

Android LマテリアルデザインAPIをダウンロードして学習を開始しました。アクティビティで CardView を使用するたびに、このエラーが発生しますFailed to find style with id 0x7f070001 in current theme

これは私のxmlレイアウトです:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.flip.tesla"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.flip.tesla.MainActivity$PlaceholderFragment" >

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    app:cardElevation="10dp" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textSize="15sp" />
</android.support.v7.widget.CardView>

</RelativeLayout>

そして、これは私のマニフェストファイルです:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<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>

これは、表示される正確なメッセージです。

スタイルがありません。このレイアウトに適切なテーマが選択されていますか? レイアウトの上にある [テーマ] コンボ ボックスを使用して、別のレイアウトを選択するか、テーマ スタイルの参照を修正します。

現在のテーマで ID 0x7f070001 のスタイルが見つかりませんでした

編集:だから私は日食を再起動しました。これは表示される新しいメッセージです。

レンダリング中に発生する例外: com.android.layoutlib.bridge.MockView は android.view.ViewGroup にキャストできません 例外の詳細は [ウィンドウ] > [ビューの表示] > [エラー ログ] に記録されます 次のクラスをインスタンス化できませんでした: - android.support.v7. widget.CardView

それが何を意味するかについてのアイデアはありますか?

4

6 に答える 6

7

これは、Gradle 同期に関連する問題です。ツールバーの更新ボタンをクリックしてみてください

于 2015-07-29T23:50:43.087 に答える
1

アプリケーションを実行してみて、出力が表示されるかどうかを確認してください

于 2014-11-09T12:57:59.843 に答える