當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。