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


Java DataBindingUtil.setContentView方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:harrynp,项目名称:BakingApp,代码行数:21,代码来源:StepDetailActivity.java

示例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();

}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:18,代码来源:MovieDetailActivity.java

示例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();
        }
    });
}
 
开发者ID:cyrilpillai,项目名称:GreenDao-Migrator,代码行数:19,代码来源:PersonActivity.java

示例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();

}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:8,代码来源:ModuleAMainActivity.java

示例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);

}
 
开发者ID:EngrAhsanAli,项目名称:AACustomFont,代码行数:11,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Orange-OpenSource,项目名称:OCast-Java,代码行数:35,代码来源:MainActivity.java

示例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);
}
 
开发者ID:harrynp,项目名称:BakingApp,代码行数:10,代码来源:MainActivity.java

示例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);

    }
 
开发者ID:JarvanMo,项目名称:CommonLibrary,代码行数:35,代码来源:Main2Activity.java

示例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()));
        }
    });

}
 
开发者ID:mplacona,项目名称:arduwrap,代码行数:29,代码来源:MainActivity.java

示例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);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:16,代码来源:MainActivity.java

示例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);
    }
 
开发者ID:yzzslow0,项目名称:Ec2m,代码行数:11,代码来源:DataBindActivity.java

示例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");
}
 
开发者ID:alidili,项目名称:Demos,代码行数:9,代码来源:CustomAttributeActivity.java

示例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();
}
 
开发者ID:amrro,项目名称:firestore-android-arch-components,代码行数:39,代码来源:RestaurantDetailActivity.java

示例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();
            }
        });
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:TransitionActivity.java

示例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);
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:12,代码来源:DataBindingActivity.java


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