本文整理匯總了Java中android.databinding.DataBindingUtil.setContentView方法的典型用法代碼示例。如果您正苦於以下問題:Java DataBindingUtil.setContentView方法的具體用法?Java DataBindingUtil.setContentView怎麽用?Java DataBindingUtil.setContentView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.databinding.DataBindingUtil
的用法示例。
在下文中一共展示了DataBindingUtil.setContentView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_step_detail);
setSupportActionBar(mBinding.stepDetailToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getIntent() != null) {
if (getIntent().hasExtra(STEP_EXTRA)){
step = Parcels.unwrap(getIntent().getParcelableExtra(STEP_EXTRA));
getSupportActionBar().setTitle(step.getShortDescription());
}
}
if (savedInstanceState != null) {
fragment = (StepDetailFragment) getSupportFragmentManager().getFragment(savedInstanceState, "stepDetailFragment");
} else {
fragment = StepDetailFragment.newInstance(step, true);
getSupportFragmentManager().beginTransaction().replace(R.id.step_fragment_container, fragment).commit();
}
}
示例2: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_movie_detail);
if (getIntent() != null) {
subjectsBean = (SubjectsBean) getIntent().getSerializableExtra("bean");
}
initSlideShapeTheme();
// 數據配置
setTitleBar();
setHeaderData(subjectsBean);
loadMovieDetail();
}
示例3: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this,
R.layout.activity_person);
binding.rvPeoples.setLayoutManager(new LinearLayoutManager(this));
binding.rvPeoples.setHasFixedSize(true);
personAdapter = new PersonAdapter(this);
binding.rvPeoples.setAdapter(personAdapter);
getListOfPeople();
binding.fabAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addItem();
}
});
}
示例4: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMainActivity = DataBindingUtil.setContentView(this, R.layout.modulea_activity_main);
init();
}
示例5: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AACustomFont.getInstance(this)
.setAlias("myfont", "Budidaya-Regular.otf")
.setDefaultFontName("myfont");
DataBindingUtil.setContentView(this, R.layout.activity_main);
}
示例6: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CallbackThreadHandler.init(new MainThreadWrapper());
if(BuildConfig.DEBUG) {
//adb shell setprop log.tag.ocast.driver.link VERBOSE
//adb shell setprop log.tag.ocast.driver.link OFF
try {
InputStream ins = getResources().openRawResource(R.raw.logging);
DebugHelper.initLogging(ins);
} catch (IOException e) {
Log.e(TAG, "could not initialize logger");
}
}
ActivityMainBinding binding = DataBindingUtil.setContentView(this,R.layout.activity_main );
viewmodel = new ViewModel(getString(R.string.webapp_id), this);
binding.setViewmodel(viewmodel);
setSupportActionBar(binding.myToolbar);
binding.buttonStart.setOnClickListener(v->startWebApp());
binding.buttonStop.setOnClickListener(v-> stopWebApp());
binding.buttonJoin.setOnClickListener(v-> joinWebApp());
binding.buttonPlayMedia.setOnClickListener(v -> playMedia());
binding.buttonPauseMedia.setOnClickListener(v-> pauseMedia());
binding.buttonStopMedia.setOnClickListener(v -> stopMedia());
OCastRouteHelper.addMediaRouteProvider(getApplicationContext(), Arrays.asList(ReferenceDriver.SEARCH_TARGET));
DeviceManager.registerDriver("Orange SA", new ReferenceDriver.ReferenceFactory());
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(OCastMediaRouteProvider.CATEGORY_OCAST)
.build();
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallBack, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例7: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (BuildConfig.DEBUG){
Timber.plant(new Timber.DebugTree());
}
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
setSupportActionBar(mBinding.toolbar);
}
示例8: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMain2Binding binding = DataBindingUtil.setContentView(this,R.layout.activity_main2);
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();
}
});
List<Test> data = new ArrayList<>();
Test test;
for (int i = 0; i < 100; i++) {
test = new Test();
test.name = i +"";
test.time = System.currentTimeMillis() + "->"+i;
data.add(test);
}
adapter.setData(data);
binding.content.rc.setLayoutManager(new LinearLayoutManager(this));
binding.content.rc.setAdapter(adapter);
}
示例9: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
FloatingActionButton fab = binding.floatingActionButton;
mTemperature = binding.temperatureTv;
mHumidity = binding.humidityTv;
Arduino mArduino = new Arduino.ArduinoBuilder()
.uartDeviceName(UART_DEVICE_NAME)
.baudRate(BAUD_RATE)
.dataBits(DATA_BITS)
.stopBits(STOP_BITS)
.build();
dht22Driver = new Dht22Driver(mArduino);
dht22Driver.startup();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTemperature.setText(String.format("%s°C", dht22Driver.getTemperature()));
mHumidity.setText(String.format("%s%%", dht22Driver.getHumidity()));
}
});
}
示例10: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* DataBindUtil.setContentView replaces our normal call of setContent view.
* DataBindingUtil also created our ActivityMainBinding that we will eventually use to
* display all of our data.
*/
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
BoardingPassInfo fakeBoardingInfo = FakeDataUtils.generateFakeBoardingPassInfo();
displayBoardingPassInfo(fakeBoardingInfo);
}
示例11: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_data_bind);
ActivityDataBindBinding bindBinding = DataBindingUtil.setContentView(this,R.layout.activity_data_bind);
dataBindTest = new DataBindTest();
bindBinding.setTest(dataBindTest);
eventHandler = new EventHandler(dataBindTest);
bindBinding.setDianiji(eventHandler);
}
示例12: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCustomAttributeBinding binding = DataBindingUtil.setContentView(this,
R.layout.activity_custom_attribute);
binding.setUrl("http://i7.qhmsg.com/t01b48a6f15bf0cf5c1.jpg");
}
示例13: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_restaurant_detail);
// Get restaurant ID from extras
final String restaurantId = getIntent().getExtras().getString(KEY_RESTAURANT_ID, null);
if (restaurantId == null) {
throw new IllegalArgumentException("Must pass extra " + KEY_RESTAURANT_ID);
}
initRecycler();
viewModel = getViewModel(RatingViewModel.class);
viewModel.setRestaurantId(restaurantId).ratings().observe(this, listResource -> {
if (listResource.isSuccessful()) {
adapter.replace(listResource.data());
}
});
viewModel.restaurant().observe(this, response -> {
if (response.isSuccessful()) {
binding.setRestaurant(response.data());
} else {
Toast.makeText(this, response.error().getMessage(), Toast.LENGTH_SHORT).show();
Timber.e(response.error());
}
});
binding.setHandler(backPressed -> {
if (backPressed) {
onBackPressed();
return;
}
mRatingDialog.show(getSupportFragmentManager(), RatingDialogFragment.TAG);
});
mRatingDialog = new RatingDialogFragment();
}
示例14: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_transition);
int i = new Random().nextInt(ConstantsImageUrl.TRANSITION_URLS.length);
// 先顯示默認圖
mBinding.ivDefultPic.setImageDrawable(CommonUtils.getDrawable(R.drawable.img_transition_default));
Glide.with(this)
.load(ConstantsImageUrl.TRANSITION_URLS[i])
.placeholder(R.drawable.img_transition_default)
.error(R.drawable.img_transition_default)
.into(mBinding.ivPic);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mBinding.ivDefultPic.setVisibility(View.GONE);
}
}, 1500);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
toMainActivity();
}
}, 3500);
// Animation animation = AnimationUtils.loadAnimation(this, R.anim.transition_anim);
// animation.setAnimationListener(animationListener);
// mBinding.ivPic.startAnimation(animation);
mBinding.tvJump.setOnClickListener(new PerfectClickListener() {
@Override
protected void onNoDoubleClick(View v) {
toMainActivity();
// animationEnd();
}
});
}
示例15: onCreate
import android.databinding.DataBindingUtil; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DatabindingTestBinding binding = DataBindingUtil.setContentView(this, R.layout.databinding_test);
Entry entry = new Entry();
entry.setText("文本數據1");
entry.setColor(0xff0000ff);
//設置測試字符串
binding.setStr("我是監聽綁定的數據測試");
binding.setEntry(entry);
}