R.styleable не может быть решена - PullRequest
2 голосов
/ 26 ноября 2010

хай друзья ... мой java файл указывает эту ошибку R.styleable не может быть решен ....

мой xml файл:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" 
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/videoGrdVw" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:numColumns="auto_fit" 
     android:verticalSpacing="5dip" 
     android:horizontalSpacing="5dip" 
     android:columnWidth="80dip" 
     android:stretchMode="columnWidth" 
     android:gravity="center"/> 

 <ImageSwitcher 

    android:id="@+id/switcher" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent">

    </ImageSwitcher>
    <resources>
    <declare-styleable name="HelloGallery">
    <attr name="android:galleryItemBackground" />
    </declare-styleable>
    </resources>


    </LinearLayout>

исходный код:

private class VideoGalleryAdapter extends BaseAdapter
{
     private int itemBackground;

    public VideoGalleryAdapter(Context c) 
    {
        _context = c;
        TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
        itemBackground = a.getResourceId(
                R.styleable.Gallery1_android_galleryItemBackground, 0);
        a.recycle(); 
    }

Ответы [ 3 ]

4 голосов
/ 05 сентября 2013

создайте XML-файл в папке values с именем attributes.xml и скопируйте в него содержимое ниже.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="Gallery1">
        <attr name="android:galleryItemBackground"/>
    </declare-styleable>
</resources>

Это должно работать.

3 голосов
/ 26 ноября 2010

Согласно этой ветке форума вам необходимо изменить:

TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);

на

TypedArray a = c.obtainStyledAttributes(R.styleable.Gallery1);
0 голосов
/ 03 февраля 2011

Для меня это помогло:

import android.R;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...