本文整理匯總了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;
}
示例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;
}
}
示例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());
}
示例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;
}
};
}
示例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);
}
}
});
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
};
}
示例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);
}
示例11: SwordsmanViewHolder
import android.databinding.ViewDataBinding; //導入依賴的package包/類
public SwordsmanViewHolder(ViewDataBinding binding) {
super(binding.getRoot());
this.binding = (ItemSwordsmanBinding) binding;
}
示例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);
}
}
}
示例13: BookViewHolder
import android.databinding.ViewDataBinding; //導入依賴的package包/類
public BookViewHolder(ViewDataBinding binding, int variableId) {
super(binding.getRoot());
mBinding = binding;
mVariableId = variableId;
}
示例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);
}
}
示例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);
}
}