2012-05-15 81 views
13

首先,我是Android新手。 我正在做一个应用程序,我正在实施一个名为HoloEverywhere的库。 这个库在themes.xml中使用库ActionBar Sherlock。我已经导入到我的工作区ActionBar Sherlock,并将其添加到HoloEverywhere。 接下来,我已经加入HoloEverywhere到我的项目,但是当我尝试使用它,我有一个错误(我试图用一个按钮):导入HoloEverywhere时出错

The following classes could not be instantiated: 
- com.WazaBe.HoloEverywhere.ButtonHolo (Open Class, Show Error Log) 
See the Error Log (Window > Show View) for more details. 
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse. 

我把类的路径在我的布局,像这样:

<com.WazaBe.HoloEverywhere.ButtonHolo 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/text" /> 

我该如何解决这个问题,并在我的项目中使用这个库?谢谢:) PS。对不起,我的英语,我知道它不是很好。

+0

你好,我是Christophe(或Waza_be),这是我第一次看到这样的错误!如果我找到了一些东西,我会来回答你的! –

+0

我做了一些步骤,但我在pom.xml文件中得到这个错误:在这一行发现多个注释: - 未能转移org.apache.maven.plugins:maven-enforcer-plugin:pom:1。将http:// repo.maven.apache.org/maven2中的0缓存在本地存储库中,直到中央的更新时间间隔过去或强制更新后才会重新解析分辨率。原始错误:无法传输工件org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0 from/to central(http://repo.maven.apache.org/ maven2):操作被取消。 - 项目构建错误:无法解析的构建扩展插件 – mahdi

+0

http://stackoverflow.com/a/20895081/623694 –

回答

39

按照以下(从博客here采取)添加ActionBarSherlock

  1. Download的.zip/.tgz的,并提取其
  2. 转到Eclipse和选择File->New-> Android Project
  3. 选择Create project from existing source和步骤然后browselibrary文件夹里面提取AndroidBarSherlock文件夹
  4. 构建目标应是最新(14或15),但是你的minSdkVersion可以少(7或8)
  5. Finish
  6. 对上新建的项目,点击并进入Properties
  7. Android标题下,您应该看到Library的部分,其复选框IsLibrary。确保已选中。
  8. 右键单击 - >您想要在Android标题下添加AndroidBarSherlock的项目的适当物品,Library部分选择Add
  9. 您应该看到ActionBarSherlock库,将其添加到您的项目
  10. 最后,如果你使用的兼容性支持,你需要删除罐子因为它包含在ActionBarSherlock。

按照以下步骤从GitHub添加HoloEverywhere

  1. Download邮编到您的计算机
  2. 解压缩的文件夹
  3. 转到Eclipse和选择File->New-> Android Project
  4. 选择Create project from existing source然后browseHoloEverywhereLib文件夹内提取folde r
  5. Finish
  6. 右键单击新创建的项目并转至Properties
  7. Android标题下,您应该看到Library的部分,其复选框IsLibrary。确保已选中并按Add和之前添加的库ActionBarSherlock

按照以下步骤添加HoloEverywhere到项目

  1. 创建一个新的Android项目
  2. 右键点击项目 - >属性 - > Android的 - >添加,同时添加ActionBarSherlockHoloEverywhere
  3. Android Manifest更改为以下

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Holo.Theme">

  4. 编辑您main.xml以包含Holo主题小工具。

  5. 更改activity如下

    public class ChkActionBarSherlock extends SherlockActivity { 
        @Override 
        public void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.main); 
        } 
    
    } 
    
+0

:我遵循你的步骤全部每个地方,但它显示在这行上的Dialogholo.java错误查看customView = View。 inflate(mContext,R.layout.alert_dialog_holo, \t \t \t \t null); \t \t mTitle =(TextView)customView.findViewById(R.id.alertTitle); R无法解析错误,Holoalertdialogbuilder.java在这个文件中的错误是在这一行\t mTitle =(TextView)customTitle.findViewById(R.id.alertTitle); \t \t \t FontLoader.loadFont(mTitle,FontLoader.ROBOTO_REGULAR); \t \t \t mIcon =(ImageView)customTitle.findViewById(R.id.icon); \t \t \t setCustomTitle(customTitle); – 2012-07-21 14:12:29

+0

你的问题看起来像'R无法解决'。清理你的项目并尝试搜索错误。网络上的大量数据。 –

+0

:我试过所有的东西都没有工作。当我导入holoeverywhere lib到月蚀只有,我得到所有这些错误 – 2012-07-21 14:23:34

4

我对我的项目同样的错误,这是我做的,右击HoloEverywhere(属性 - > android->库)中删除然后从列表中重新添加ActionBarSherlock项目,然后清理项目,所有错误都会消失。

8

似乎

android:theme="@style/Theme.HoloEverywhereDark.Sherlock" 

原因的错误。

改变它:

android:theme="@style/Holo.Theme" 

resons这里:

Github

正确的!

0

ActionBarSherlock的创始人Jake Wharton在Google+上宣布,ActionBarSherlock的进一步开发已经停止。 ActionBarSherlock 4.4是最后的版本,并可能会得到错误修正 - 但不会有任何新的特点:

While there may be a dot release or two in the coming weeks, version 4.4 is shaping up to be The Last Release™.

https://plus.google.com/+JakeWharton/posts/F3HkWY9J8fK

正如我问上holoeverywhere issues forum,并通过开发者回答说:

HoloEverywhere doesn't have any dependency with ABS since v2.0

所以你不应该再使用ABS了,从你的项目中移除库并直接替换它,直接替换它,或者用谷歌支持库中的ActionbarCompat替换它。