当前位置: 首页>>代码示例>>Java>>正文


Java ViewDataBinding类代码示例

本文整理汇总了Java中android.databinding.ViewDataBinding的典型用法代码示例。如果您正苦于以下问题:Java ViewDataBinding类的具体用法?Java ViewDataBinding怎么用?Java ViewDataBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ViewDataBinding类属于android.databinding包,在下文中一共展示了ViewDataBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateViewHolder

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
public MultiRecyclerViewAdapter.BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ViewDataBinding binding;

    if (viewType == 0) {
        binding = DataBindingUtil.inflate(
                LayoutInflater.from(parent.getContext()), R.layout.adapter_recycler_view_other, parent, false);
    } else {
        binding = DataBindingUtil.inflate(
                LayoutInflater.from(parent.getContext()), R.layout.adapter_recycler_view, parent, false);
    }

    BindingHolder holder = new BindingHolder(binding.getRoot());
    holder.setBinding(binding);
    return holder;
}
 
开发者ID:alidili,项目名称:Demos,代码行数:17,代码来源:MultiRecyclerViewAdapter.java

示例2: convert

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected void convert(MovieViewHolder helper, Movie item) {
    ViewDataBinding binding = helper.getBinding();
    binding.setVariable(BR.movie, item);
    binding.setVariable(BR.presenter, mPresenter);
    binding.executePendingBindings();
    switch (helper.getLayoutPosition() %
            2) {
        case 0:
            helper.setImageResource(R.id.iv, R.mipmap.m_img1);
            break;
        case 1:
            helper.setImageResource(R.id.iv, R.mipmap.m_img2);
            break;

    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DataBindingUseAdapter.java

示例3: convert

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected void convert(BaseBindHolder helper, WeatherDailyResponse.DailyResult.Daily item) {
    ViewDataBinding binding = helper.getBinding();
    binding.setVariable(BR.daily, item);
    binding.executePendingBindings();

    SuperTextView superTextView = helper.getView(R.id.super_item_daily);
    ArmsUtils.INSTANCE.obtainArmsComponent(mContext).imageLoader()
            .loadImage(mContext,
                    ImageConfigImpl.builder()
                            .url(String.format(Locale.CHINESE, Api.API_WEATHER_ICON_URL, item.getCodeDay()))
                            .placeholder(R.mipmap.ic_placeholder)
                            .errorPic(R.mipmap.weather_unknown)
                            .transformation(new FitCenter())
                            .imageView(superTextView.getRightIconIV())
                            .build());
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:18,代码来源:WeatherDailyAdapter.java

示例4: activityCompatInterface

import android.databinding.ViewDataBinding; //导入依赖的package包/类
/**
 * Generate an ActivityCompatInterface with given activity and binding.
 *
 * @param activity
 * @param binding
 * @param <V>
 * @return
 */
public static <V extends ViewDataBinding> ActivityCompatInterface<V> activityCompatInterface(final AppCompatActivity activity, final V binding) {
    return new ActivityCompatInterface<V>() {
        @Override
        public AppCompatActivity getCompatActivity() {
            return activity;
        }

        @Override
        public Context getContext() {
            return activity;
        }

        @Override
        public V getBinding() {
            return binding;
        }
    };
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:27,代码来源:ViewInterfaceGen.java

示例5: ItemViewHolder

import android.databinding.ViewDataBinding; //导入依赖的package包/类
public ItemViewHolder(ViewDataBinding binding) {
    super(binding);

    itemModel = new ItemModel();
    ReflectionHelper.run(binding,"set",itemModel);

    itemModel.selected.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            if(!updateSelected)
                return;
            if(selectedItems == null)
                return;
            if(selectedItems.contains(model)){
                if(allowMultipleSelection){
                    selectedItems.remove(model);
                }
            }else{
                if(!allowMultipleSelection){
                    selectedItems.clear();
                }
                selectedItems.add(model);
            }
        }
    });
}
 
开发者ID:neurospeech,项目名称:ui-atoms-android,代码行数:27,代码来源:AtomListView.java

示例6: showCustomDialog

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected void showCustomDialog(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) {
    // show a dialog; make sure to register a custom dialog handler in the settings setup once!!!
    // this one then is responsible to save a user changed value
    Data data = getValue(customSettingsObject, global);

    // for this demo we use a single image picker for global values only, so we use this example image picker;
    // normally you would need a dialog you can add the settings id to so that the dialog can dispatch the selection event and
    // the settings manager can handle it
    // for this demo we simply handle the image select event in the activity and as we know
    // that we have a single setting for this event only we also now the settings id to use for disatching the event
    ImagePicker.with(activity)
            .setCameraOnly(false)
            .setMultipleMode(false)
            .setFolderMode(true)
            .setFolderTitle("Albums")
            .setImageTitle("Galleries")
            .setDoneTitle("Done")
            .setSavePath("ImagePicker")
            .start();
}
 
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:22,代码来源:CustomImageSetting.java

示例7: getItemView

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected View getItemView(int layoutResId, ViewGroup parent) {
    ViewDataBinding binding = DataBindingUtil.inflate(mLayoutInflater, layoutResId, parent, false);
    if (binding == null) {
        return super.getItemView(layoutResId, parent);
    }
    View view = binding.getRoot();
    view.setTag(R.id.BaseQuickAdapter_databinding_support, binding);
    return view;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:DataBindingUseAdapter.java

示例8: setDataBindingVariables

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
  LayoutCombineChartBinding b = (LayoutCombineChartBinding) binding;
  CandlestickDataSet dataSet = new CandlestickDataSet(candlestickValues);
  dataSet.setHighlightedVerticalEnable(true);

  b.combineChart.getAxisLeft().setAxisPosition(LEFT_OUTSIDE);
  b.combineChart.getAxisRight().setAxisPosition(RIGHT_INSIDE);
  b.combineChart.setMaxVisibleEntryCount(20);
  b.combineChart.setHighlightColor(Color.BLACK);
  b.combineChart.setOnHighlightStatusChangeListener(highlightStatusChangeListener);
  b.combineChart.setDataSet(dataSet);
}
 
开发者ID:donglua,项目名称:JZAndroidChart,代码行数:13,代码来源:CandlestickChartModel.java

示例9: viewInterface

import android.databinding.ViewDataBinding; //导入依赖的package包/类
/**
 * Generate a ViewInterface with a given binding.
 *
 * @param binding the binding
 * @param <V>     the type of the binding.
 * @return a ViewInterface with a context and a binding.
 */
public static <V extends ViewDataBinding> ViewInterface<V> viewInterface(final V binding) {
    return new ViewInterface<V>() {
        @Override
        public Context getContext() {
            return binding.getRoot().getContext();
        }

        @Override
        public V getBinding() {
            return binding;
        }
    };
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:21,代码来源:ViewInterfaceGen.java

示例10: onCreateViewHolder

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
public BindingViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ViewDataBinding binding;
    if (viewType == ITEM_VIEW_TYPE_ON) {
        binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.item_employee, parent, false);
    } else {
        binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.item_employee_off, parent, false);
    }
    return new BindingViewHolder(binding);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:11,代码来源:EmployeeAdapter.java

示例11: SwordsmanViewHolder

import android.databinding.ViewDataBinding; //导入依赖的package包/类
public SwordsmanViewHolder(ViewDataBinding binding) {
    super(binding.getRoot());
    this.binding = (ItemSwordsmanBinding) binding;
}
 
开发者ID:henrymorgen,项目名称:android-advanced-light,代码行数:5,代码来源:SwordsmanAdapter.java

示例12: bind

import android.databinding.ViewDataBinding; //导入依赖的package包/类
private static void bind(ViewGroup viewGroup, ItemView itemView, List<?> viewModelList, final OnItemClickListener<?> onItemClickListener) {
    if (viewModelList != null && !viewModelList.isEmpty()) {
        viewGroup.removeAllViews();
        for (int pos=0; pos<viewModelList.size(); pos++) {
            final Object viewModel = viewModelList.get(pos);
            final ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()),
                    itemView.layoutRes(), viewGroup, true);
            binding.setVariable(itemView.bindingVariable(), viewModel);

            setListener(onItemClickListener, ViewHolder.createViewHolder(viewGroup.getContext(), binding.getRoot()), viewModel, pos);
        }
    }
}
 
开发者ID:fashare2015,项目名称:MVVM-JueJin,代码行数:14,代码来源:ViewGroupAdapter.java

示例13: BookViewHolder

import android.databinding.ViewDataBinding; //导入依赖的package包/类
public BookViewHolder(ViewDataBinding binding, int variableId) {
  super(binding.getRoot());
  mBinding = binding;
  mVariableId = variableId;
}
 
开发者ID:douo,项目名称:ActivityBuilder,代码行数:6,代码来源:BookListAdapter.java

示例14: onCreate

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ViewDataBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_currencies);
    binding.setVariable(BR.model, mViewModel);
    if (!isRetained(savedInstanceState)) {
        mViewModel.onLoad(null);
    }
}
 
开发者ID:krokers,项目名称:exchange-rates-mvvm,代码行数:10,代码来源:CurrenciesActivity.java

示例15: setDataBindingVariables

import android.databinding.ViewDataBinding; //导入依赖的package包/类
@Override
protected void setDataBindingVariables(ViewDataBinding binding) {
    if (binding instanceof LayoutBarChartBinding) {

        LayoutBarChartBinding barBinding = (LayoutBarChartBinding) binding;

        barBinding.barChart.setDataSet(barDataSet);
        barBinding.barChart.getAxisRight().setLabelTextColor(Color.BLACK);
    }
}
 
开发者ID:donglua,项目名称:JZAndroidChart,代码行数:11,代码来源:BarChartModel.java


注:本文中的android.databinding.ViewDataBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。