本文整理匯總了Java中android.databinding.DataBindingUtil類的典型用法代碼示例。如果您正苦於以下問題:Java DataBindingUtil類的具體用法?Java DataBindingUtil怎麽用?Java DataBindingUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DataBindingUtil類屬於android.databinding包,在下文中一共展示了DataBindingUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityDagger2Binding binding = DataBindingUtil.setContentView(this, R.layout.activity_dagger2);
mCalendar = new Calendar();
binding.setCalendar(mCalendar);
DaggerCalendarComponent.
builder().
apiHttpModule(new ApiHttpModule()).
calendarPresenterModule(new CalendarPresenterModule(this)).
build().
inject(this);
initToolbar();
initView();
}
示例2: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getComponent().inject(this);
binding = DataBindingUtil.setContentView(this, R.layout.activity_signin);
binding.setViewmodel(viewModel);
binding.container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
binding.bottomBar.post(new Runnable() {
@Override
public void run() {
binding.bottomBar.setVisibility(binding.container.getRootView().getHeight() - binding.container.getHeight() > dpToPx(SignInActivity.this, 200) ? View.GONE : View.VISIBLE);
}
});
}
});
}
示例3: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.view_date_picker, null, true);
setContentView(binding.getRoot());
setCancelable(true);
if (getWindow() != null) {
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
findViews();
}
示例4: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
initStatusView();
initId();
initRxBus();
StatusBarUtil.setColorNoTranslucentForDrawerLayout(MainActivity.this, drawerLayout,
CommonUtils.getColor(R.color.colorTheme));
initContentFragment();
initDrawerLayout();
initListener();
}
示例5: initDrawerLayout
import android.databinding.DataBindingUtil; //導入依賴的package包/類
/**
* inflateHeaderView 進來的布局要寬一些
*/
private void initDrawerLayout() {
navView.inflateHeaderView(R.layout.nav_header_main);
View headerView = navView.getHeaderView(0);
bind = DataBindingUtil.bind(headerView);
bind.setListener(this);
bind.dayNightSwitch.setChecked(SPUtils.getNightMode());
ImgLoadUtil.displayCircle(bind.ivAvatar, ConstantsImageUrl.IC_AVATAR);
bind.llNavExit.setOnClickListener(this);
bind.ivAvatar.setOnClickListener(this);
bind.llNavHomepage.setOnClickListener(listener);
bind.llNavScanDownload.setOnClickListener(listener);
bind.llNavDeedback.setOnClickListener(listener);
bind.llNavAbout.setOnClickListener(listener);
bind.llNavLogin.setOnClickListener(listener);
}
示例6: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityLayoutBinding binding=DataBindingUtil.setContentView(this, R.layout.activity_layout);
binding.setName("風清揚");
binding.setAge(70);
binding.setMan(true);
ArrayList list=new ArrayList();
list.add("0");
list.add("1");
binding.setList(list);
Map map=new HashMap();
map.put("age","30");
binding.setMap(map);
String[] arrays = {"張無忌", "慕容龍城"};
binding.setArrays(arrays);
Swordsman swordsman=new Swordsman("獨孤求敗","SS");
binding.setSwordsman(swordsman);
binding.setTime(new Date());
}
示例7: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_tune_result);
ActivityTuneResultBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_tune_result);
TuneResult tuneResult = getIntent().getParcelableExtra(TUNE_RESULT_KEY);
binding.setTuneResult(tuneResult);
GraphView gphTuning = (GraphView) findViewById(R.id.gphTuning);
LineGraphSeries<DataPoint> tuningSeries = getLineGraph(tuneResult);
gphTuning.addSeries(tuningSeries);
gphTuning.getViewport().setScalable(true);
gphTuning.getViewport().setScrollable(true);
// Translate the graph around on a pseudo-log scale
gphTuning.getGridLabelRenderer().setLabelFormatter(new FrequencyLabelFormatter());
}
示例8: onCreateView
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_media_grid, container, false);
mContentLoadingUitl = ContentLoadingUtil.with(mContext)
.setContent(mBinding.recyclerViewMediaList)
.setProgress(mBinding.progressBarLoading)
.setError(mBinding.textViewErrorMessage);
View view = mBinding.getRoot();
if (getArguments() != null) {
mType = getArguments().getString(TYPE, DISCOVER);
}
mBinding.recyclerViewMediaList.setHasFixedSize(true);
mBinding.recyclerViewMediaList.setLayoutManager(mLayoutManager);
mAdapter = new MediaAdapter(this);
mBinding.recyclerViewMediaList.setAdapter(mAdapter);
mBinding.recyclerViewMediaList.addOnScrollListener(mEndlessScollListener);
return view;
}
示例9: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
client = new GoogleApiClient.Builder(this)
.addApi(SafetyNet.API)
.enableAutoManage(this, this)
.build();
binding.root.setText(new RootBeer(this).isRooted() ? "Device is rooted" : "Device isn't rooted");
binding.installation.setText(InstallationChecker.verifyInstaller(this) ? "Installed from Play Store" : "Installed from unknown source");
binding.enviroment.setText((EnvironmentChecker.alternativeIsEmulator() ? "Running on an emulator" : "Running on a device")
+ (EnvironmentChecker.isDebuggable(this) ? " with debugger" : ""));
binding.tampering.setText((InstallationChecker.checkPackage(this) ?
"The package is consistent" : "The package was modified")
+ (SignatureUtils.checkSignature(this) ? " and the signature is ok" : " and the signature was changed!"));
binding.setController(this);
}
示例10: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, com.github.trdevendran.queuedprogressbar.R.layout.activity_main);
mBinding.ballCountControllerSb.setOnSeekBarChangeListener(this);
mBinding.radiusControllerSb.setOnSeekBarChangeListener(this);
mBinding.speedControllerSb.setOnSeekBarChangeListener(this);
mBinding.defaultColorRb.setOnCheckedChangeListener(this);
mBinding.greenColorRb.setOnCheckedChangeListener(this);
mBinding.blueColorRb.setOnCheckedChangeListener(this);
mBinding.redColorRb.setOnCheckedChangeListener(this);
mBinding.ballCountControllerSb.setProgress(5);
mBinding.radiusControllerSb.setProgress(5);
mBinding.speedControllerSb.setProgress(5);
mBinding.defaultColorRb.setChecked(true);
}
示例11: onCreateView
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_media_grid, container, false);
mContentLoadingUtil = ContentLoadingUtil.with(mContext)
.setContent(mBinding.recyclerViewMediaList)
.setProgress(mBinding.progressBarLoading)
.setError(mBinding.textViewErrorMessage);
View view = mBinding.getRoot();
if (getArguments() != null) {
mType = getArguments().getString(TYPE, FAVORITES);
}
mBinding.recyclerViewMediaList.setHasFixedSize(true);
mBinding.recyclerViewMediaList.setLayoutManager(mLayoutManager);
mAdapter = new FavoritesAdapter(this);
mBinding.recyclerViewMediaList.setAdapter(mAdapter);
return view;
}
示例12: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
//TODO: Make Spinner example
}
示例13: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TAG = getClass().getSimpleName();
//init data binding
binding = DataBindingUtil.setContentView(this, getLayout());
initViews();
// int view model
// noinspection unchecked
Class<VM> viewModelClass = (Class<VM>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[1]; // 1 is BaseViewModel
viewModel = ViewModelProviders.of(this, viewModelFactory).get(viewModelClass);
viewModel.onCreate(getIntent().getExtras(), navigatorHelper);
viewModel.getStateLiveData().observe(this, this::handleState);
}
示例14: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_data_binding_example);
// create dummy item
NewsItem item = new NewsItem();
item.setHtml("<p>Interdum et malesuada <b>some bold text in here</b> fames ac ante ipsum primis in faucibus.</p>");
// in XML we declared a variable newsItem, data binding generated the set method
// once set, all fields/values/views are updated accordingly
binding.setNewsItem(item);
// if you have set an android:id in XML, data binding do the 'findViewById()'
DrawTableLinkSpan drawTableLinkSpan = new DrawTableLinkSpan();
drawTableLinkSpan.setTableLinkText("[tap for table]");
binding.htmlText.setDrawTableLinkSpan(drawTableLinkSpan);
}
示例15: onCreate
import android.databinding.DataBindingUtil; //導入依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.button.setOnClickListener(v -> SettingActivity.startActivity(this));
DaggerService.<MainComponent>getComponent(this).injectMembers(this);
settingStore.rotate().compose(bindToLifecycle()).subscribe(on -> {
setRequestedOrientation(on ? ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
});
log.add(this.toString());
Toast.makeText(this, "log=" + log.size() + " fm." + this, Toast.LENGTH_SHORT).show();
}