我在我的Activities上实现了一个ActionBar。我正在尝试将其作为AndroidAnnotaions @EViewGroup组件执行此操作,但出于某种原因,我无法在“活动”中看到该组件。该项目编译罚款,但。ViewGroup injection with AndroidAnnotation
我的代码基本上是类似下面
actionbar.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="@dimen/action_bar_height"
android:layout_width="match_parent"
>
<ImageButton
android:id="@+id/back"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/back_button"
/>
<!-- Rest of the views omitted -->
</RelativeLayout>
ActionBar.java
@EViewGroup(R.layout.actionbar)
public class ActionBar extends RelativeLayout {
private Context mContext;
public ActionBar(Context aContext, AttributeSet aAttributeSet) {
super(aContext);
mContext = aContext;
}
// @Click listener methods omitted
这是我如何使用它在另一个布局XML
<jandy.android.ActionBar_
android:id="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_height"
/>
根据AA文件,这是所有必需的。但如前所述,没有任何东西可见。
谢谢。
make sur that @ dimen/action_bar_height不是0 :) – Simo 2013-04-10 14:05:32
@Simo谢谢你的提示。不,它不是0.事实上,我曾将ActionBar作为一个布局的一部分。现在我正在制作其他屏幕,我希望它是一个分离和可重用组件。 – kaskelotti 2013-04-11 04:35:51