我想使用Android Studio(我遵循本教程)。

我在Project Explorer中看到了Android引导和我的项目,但如果我尝试添加Bootstrap按钮

 <!-- 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"
        />
.

我收到以下错误消息:

android-apt-compiler:layout / activity_main.xml:56:错误:在包'com.carfinder'

中没有找到属性'bb_icon_right'的资源标识符

我做错了什么?

有帮助吗?

解决方案

更新:

确保您的项目结构应该如下所示,您的库可以在某些目录中,如库中> androidbootstraibrary没有问题,在这种情况下,只有您必须在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(否。a)文件

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

settings.gradle:

  include ':YOUR_MODULE'
  include ':AndroidBootStrapLibrary'
.

在所有

毕竟使用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>
.

我在这里上传了一个工作测试项目(Checkout Form GitHub IS)

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

其他提示

以防某人在尝试添加这个库并遇到这个问题但有不同的问题,我认为值得一提的是为我工作的完整步骤(我改编了从另一个库

  1. 在Android Studio中打开您的项目
  2. 下载库(使用git或zip存档到解压缩)
  3. 转到解压缩库的文件夹> androidbootstrap> build.gradle
  4. 删除'申请:'push.gradle'
  5. 替换 integer.parseint(target_sdk_int),Integer.parseint(min_sdk_int),Integer.parseint(version_code),version_name,bersion_name,“25.0.1”与项目版本。您可以在Gradle脚本> Build.gradle中找到那些
  6. 转到文件>导入模块并导入库(只需要 androidbootstrap 文件夹,而不是分支的整个代码)
  7. 转到文件>项目结构
  8. 找到主项目模块,单击它。 (您还应该看到它下面的AndroidBootstrap)
  9. 单击它并转到依赖关系。
  10. 单击左绿色“+”按钮>模块依赖关系
  11. 选择“Androidboostrap”
  12. 现在一切都应该工作。

    当您尝试添加来自Androidboostrap库的元素时,您可能仍然会在您的.xml文件中收到错误。“命名空间”应用程序“未绑定。”。您可以通过单击Android Studio中的错误,或添加此行

    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