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