【发布时间】:2016-10-03 17:31:59
【问题描述】:
我是使用 android dataBinding 功能的新手,当我成功将其中一项活动更改为使用 dataBinding 功能时,其他活动出现错误,我找不到什么问题
我收到此错误:
Error parsing XML: duplicate attribute
duplicate attribute 是什么意思?哪个属性?
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="newChannelViewModel"
type="com.pishguy.androidapplication.appname.Views.Activities.CreateNewChannel.CreateNewChannelViewModel"/>
</data>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/content_background"
android:orientation="vertical">
<include layout="@layout/new_channel_application_toolbar"/>
<com.pishguy.androidapplication.appname.Widgets.ViewPagerCustomDuration
android:id="@+id/create_new_channel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="-25dp"
android:layout_marginRight="-25dp"/>
</LinearLayout>
</layout>
这是我的活动:
public class CreateNewChannel extends ActivityBase implements ActivityBase.connections, CreateNewChannelViewModel.OnActionListener {
...
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= 21) {
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
}
super.onCreate(savedInstanceState);
/** Set connection Listener */
setRealTimeConnectionListener(this);
CreateNewChannelBinding binding = DataBindingUtil.setContentView(this, R.layout.create_new_channel);
CreateNewChannelViewModel newChannelViewModel = new CreateNewChannelViewModel(this);
binding.setNewChannelViewModel(newChannelViewModel);
ButterKnife.bind(this);
...
}
还有这个活动ViewModel:
public class CreateNewChannelViewModel extends BaseObservable implements ViewModel {
private OnActionListener ionActionListener;
public CreateNewChannelViewModel(OnActionListener onActionListener) {
ionActionListener = onActionListener;
}
@Override
public void destroy() {
}
public interface OnActionListener {
void onClick();
}
}
什么问题,我该如何解决?
【问题讨论】:
标签: android android-databinding