質問

を追加したいと思います Android ブートストラップ ライブラリ Android Studio を使用してプロジェクトに追加 (私はフォローしました) このチュートリアル).

プロジェクト エクスプローラーに Android ブートストラップとプロジェクトが表示されますが、ブートストラップ ボタンを追加しようとすると

 <!-- basic button -->
    <com.beardedhen.androidbootstrap.BootstrapButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="Success"
        bootstrapbutton:bb_icon_right="fa-android"
        bootstrapbutton:bb_type="success"
        />

次のエラー メッセージが表示されます。

アンドロイド-apt-コンパイラー:レイアウト/アクティビティメイン.xml:56:エラー:パッケージ「com.carfinder」の属性「bb_icon_right」のリソース識別子が見つかりません

私の何が間違っているのでしょうか?

役に立ちましたか?

解決

更新しました:

プロジェクトの構造が次のようになっていることを確認してください。ライブラリは、libraries>AndroidBootStrapLibrary などのディレクトリ内に置くこともできますが、問題ありません。その場合は、settings.gradle と build.gradle のパスを変更するだけです。

    ----YOUR_PROJECT
       ---AndroidBootStrapLibrary
         --res
         --src
         -- .....
         -- build.gradle(must contain apply plugin: 'android-library' 
            if not that menas not library project you have added something wrong)
       ---YOUR_MODULE
         --res
         --src
         --build.gradle (no : A)
   ----settings.gradle

build.gradle (いいえ。ファイル

  dependencies {
       compile 'com.android.support:appcompat-v7:+'
       compile 'com.android.support:support-v4:18.0.+'
       compile project(':AndroidBootStrapLibrary')
  }

設定.gradle:

  include ':YOUR_MODULE'
  include ':AndroidBootStrapLibrary'

結局のところ、プロジェクトをGradleと同期してください

sync project with gradle

ライブラリにカスタム ビューの名前空間を追加するのを忘れました。

ボタンのコードをこれに置き換えます

     <com.beardedhen.androidbootstrap.BootstrapButton
         xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_margin="10dp"
         android:text="Success"
         bootstrapbutton:bb_icon_right="fa-android"
         bootstrapbutton:bb_type="success"
    />

使用している場合は、他のビューにも名前空間を追加します。次のように、レイアウト ファイルのルート要素に追加することもできます。

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context="com.example.app.MainActivity$PlaceholderFragment">

     <TextView
         android:text="@string/hello_world"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />

     <com.beardedhen.androidbootstrap.BootstrapButton
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_margin="10dp"
         android:text="Success"
         bootstrapbutton:bb_icon_right="fa-android"
         bootstrapbutton:bb_type="success"
    />

  </RelativeLayout>

ここに動作するテストプロジェクトを 1 つアップロードしました (AS のチェックアウトフォーム github)

https://github.com/pyus-13/TesstApp.git

他のヒント

誰かがこの図書館を追加しようとしているがこの質問に遭遇しようとしているが、問題を抱えているが問題を抱えているが、私はそれが私のために働いた完全なステップを言及する価値があると思います(私は別のライブラリこちら):

  1. Android Studio
  2. でプロジェクトを開く
  3. ライブラリ(GITを使用する、またはZIPアーカイブを使用して解凍する)
  4. ライブラリー/ androidbootstrap> build.gradle
  5. を解凍したフォルダーに移動します。
  6. 削除 '申し込み:' push.gradle '
  7. integer.parsint(target_sdk_int)、integer.parsint(min_sdk_int)、integer.parseint(version_code)、version_name、 "25.0.1" をプロジェクトのバージョンに置き換えます。 Gradle Scripts> Build.gradle
  8. にもあります。
  9. ファイル>モジュールのインポートとライブラリのインポートに移動します( androidbootstrap フォルダのみ、ブランチからのコード全体ではありません)
  10. ファイルに移動>プロジェクト構造
  11. メインプロジェクトモジュールを見つけて、それをクリックします。 (それ以外のAndroidbootstrapも参照)
  12. それをクリックして依存関係に進みます。
  13. 左緑色の「+」ボタンをクリックしてください>モジュール依存関係
  14. "androidboostrap"
  15. を選択

    そして今すべてがうまくいくべきです。

    AndroidbooStrapライブラリ "namespace 'app'がバインドされていない要素を追加しようとすると、.xmlファイルにエラーが発生する可能性があります。"これを解決するには、Android StudioのエラーのAlt + Enterキーをクリックするか、この行を追加するか、この行を追加することで解決できます。

    xmlns:app="http://schemas.android.com/apk/res-auto"
    
    .

    宣言またはレイアウトとXMLNSの後:ツールe.g

    <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-auto"
    
    .

    私は私がAndroid初心者としてライブラリを含める方法について最も正確な解決策であるかどうかわかりませんが、それは私のために働いていました。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top