我下载了 ActionBarSherlock 版本 4.1.0.0,并在我的 Win7 java 1.6 update 24 机器上将 Android 项目库添加到 Eclipse 4.2 中。我在 Project | 中使用了 Android 4.1 的 Eclipse 项目构建目标。属性 | 项目构建目标。我想将 ActionBar 功能合并到具有 minSdkVersion="7" 的现有应用程序中。我注意到 ActionBarSherlock 库中的代码似乎有一些不推荐使用的方法,并且出现错误:
示例 1:ActionBarContainer.java、ActionBarContextView.java、ScrollingTabContainerView.java - 使用 setBackgroundDrawable - 不推荐使用 View 类型的方法 setBackgroundDrawable(Drawable)
public ActionBarContainer(Context context, AttributeSet attrs) {
super(context, attrs);
setBackgroundDrawable(null);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SherlockActionBar);
mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
mStackedBackground = a.getDrawable(
R.styleable.SherlockActionBar_backgroundStacked);
if (getId() == R.id.abs__split_action_bar) {
mIsSplit = true;
mSplitBackground = a.getDrawable(
R.styleable.SherlockActionBar_backgroundSplit);
}
a.recycle();
setWillNotDraw(mIsSplit ? mSplitBackground == null :
mBackground == null && mStackedBackground == null);
}
快速修复显示为 ActionBarContainer 的 Add @SupressWarnings 'deprecation'
示例 2:IcsProgressBar.java 使用显示为已弃用的 animationResolution,与上述相同的快速修复
private static final int[] ProgressBar = new int[] {
...
android.R.attr.animationResolution
另外,我在 ActivityChooserView.java 中有一个错误:
private static class SetActivated {
public static void invoke(View view, boolean activated) {
view.setActivated(activated);
}
}
SetActivated 出现错误 - 调用需要 API 11(当前最小值为 7)。根据清单,这是有道理的:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
API 7 不应该没问题吗,因为 Action Bar Sherlock 应该在 Andriod 2.x 上工作?其他人是否经历过这种情况,如果有,建议采取什么措施?抑制/忽略弃用?SetActivated 上的错误怎么办?我查看了自述文件并进行了一些网络搜索,但没有对此提出任何建议。感谢您的任何建议。
谢谢!