2014-10-29 20 views
16

Tôi vừa tải xuống và bắt đầu học thiết kế material design android L. Bất cứ khi nào tôi sử dụng CardView trong hoạt động của tôi nó mang lại cho tôi lỗi này Failed to find style with id 0x7f070001 in current theme."Không thể tìm thấy kiểu có id 0x7f070001 trong chủ đề hiện tại" khi sử dụng CardView android L (api 21)

Đây là bố cục xml của tôi:

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

Và đây là file manifest của tôi:

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

và đây là thông điệp chính xác nó sẽ hiển thị:

phong cách Thiếu. Chủ đề chính xác đã được chọn cho bố cục này chưa? Sử dụng hộp tổ hợp Chủ đề phía trên bố cục để chọn bố cục khác hoặc sửa tham chiếu kiểu chủ đề.

Không thể tìm thấy phong cách với id 0x7f070001 trong chủ đề hiện tại

EDIT: Vì vậy, tôi khởi động lại eclipse đây là tin nhắn mới nó sẽ hiển thị.

ngoại lệ huy động trong khi hiển thị: com.android.layoutlib.bridge.MockView không thể được đúc để android.view.ViewGroup chi tiết ngoại lệ được ghi trong Window> Show View> Lỗi Log Các lớp sau đây không thể được khởi tạo : - android.support.v7.widget.CardView

bất kỳ ý tưởng nào về ý nghĩa của nó?

Trả lời

1

Thử chạy ứng dụng và xem nó có hiển thị đầu ra

6

Đó là sự cố liên quan đến đồng bộ hóa Gradle. Hãy thử nhấp vào nút refresh trên thanh công cụ

+1

Tôi gặp sự cố này và đồng bộ hóa Gradle không khắc phục vấn đề cho đến khi tôi thay đổi 'compileSdkVersion' thành một phiên bản khác và sau đó thay đổi nó ba ck đến nơi tôi muốn nó – CrandellWS

+2

Thật khó chịu khi thấy những trục trặc nhỏ như vậy. ** Làm sạch dự án ** theo sau là một ** xây dựng lại ** đã làm việc cho tôi. – vvy

1

đặt android.support.v7.widget.CardView như bố trí cha mẹ của bạn thay vì RelativeLayout,

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_gravity="center" 
card_view:cardCornerRadius="4dp" > 

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="2dp" 
    android:orientation="vertical" 
    android:weightSum="100" > 
0

cố gắng sử dụng mã này trong phong cách hoạt động của bạn

<style name="StyledIndicators" parent="@android:style/Theme.Light"> 
    <item name="vpiCirclePageIndicatorStyle">@style/CustomCirclePageIndicator</item> 
</style> 

<style name="CustomCirclePageIndicator"> 
    <item name="fillColor">#000000</item> 
    <item name="strokeColor">#000000</item> 
    <item name="strokeWidth">1dp</item> 
    <item name="radius">6dp</item> 
    <item name="centered">true</item> 
</style> 

xem liên kết này failed-to-find-style-vpicirclepageindicatorstyle

Các vấn đề liên quan