2012-01-15 26 views
3

私はImageViewの 『』 [Accessibility] Missing contentDescription attribute on image」の前にこの警告を持っていたし、私はそれにこのコードを追加:ませリソース識別子ません「アンドロイド

android:contentDescription="@string/desc" 

、今私が直面していますエラー

No resource identifier found for attribute 'contentDescription' in package 'android 

は、これは私のコードです:

<ImageView 
      android:id="@+id/handle" 
      android:layout_width="48dip" 
      android:layout_height="48dip" 
      android:contentDescription="@string/desc" 
      android:src="@drawable/icon" 
      /> 
+0

エラーの回答ではありませんが、警告を無視しても問題ありません。 – Nanne

+0

最初の場所で警告とエラーは2つしかないので、私はとても混乱しましたが、実行できませんでした。アプリケーション、私は理由を知らない! – user1143529

答えて

1

android:contentDescription属性を使用する場合は、descという文字列リソースをプロジェクトに追加する必要があります(たとえば、res/values/strings.xml)。

+0

私はすでにdesc stringリソースを持っています。しかし、まだ動作しません。 – user1143529

+7

@ user1143529:APIレベル4で 'android:contentDescription'が追加されました。ビルドターゲットをAPIレベル4以上に設定します。 – CommonsWare

1

あなたの要素のためのcontentDescriptionでの必要はありません確信している場合は念のために、あなたはlintはそれを無視することができます:

  1. xmlns:tools="http://schemas.android.com/tools"名前空間
  2. を追加するには、要素にtools:ignore="contentDescription"属性を追加します。
関連する問題