Search in sources :

Example 1 with User

use of com.liangfeizc.databinding.model.User in project MasteringAndroidDataBinding by LyndonChin.

the class ViewStubActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_view_stub);
    mBinding.viewStub.setOnInflateListener(new ViewStub.OnInflateListener() {

        @Override
        public void onInflate(ViewStub stub, View inflated) {
            ViewStubBinding binding = DataBindingUtil.bind(inflated);
            User user = new User("liang", "fei");
            binding.setUser(user);
        }
    });
}
Also used : ViewStub(android.view.ViewStub) User(com.liangfeizc.databinding.model.User) View(android.view.View) ViewStubBinding(com.liangfeizc.databinding.databinding.ViewStubBinding) ActivityViewStubBinding(com.liangfeizc.databinding.databinding.ActivityViewStubBinding)

Example 2 with User

use of com.liangfeizc.databinding.model.User in project MasteringAndroidDataBinding by LyndonChin.

the class BasicActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityBasicBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_basic);
    User user = new User("fei", "Liang", 27);
    binding.setUser(user);
}
Also used : ActivityBasicBinding(com.liangfeizc.databinding.databinding.ActivityBasicBinding) User(com.liangfeizc.databinding.model.User)

Example 3 with User

use of com.liangfeizc.databinding.model.User in project MasteringAndroidDataBinding by LyndonChin.

the class IncludeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_include);
    binding.setListener(this);
    binding.setOkText("to toast");
    //in order to get the etName, you must define an id for the include tag.
    binding.layoutInput.etName.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            User user = new User(s.toString(), "Liang");
            binding.setUser(user);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : User(com.liangfeizc.databinding.model.User) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Aggregations

User (com.liangfeizc.databinding.model.User)3 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 ViewStub (android.view.ViewStub)1 ActivityBasicBinding (com.liangfeizc.databinding.databinding.ActivityBasicBinding)1 ActivityViewStubBinding (com.liangfeizc.databinding.databinding.ActivityViewStubBinding)1 ViewStubBinding (com.liangfeizc.databinding.databinding.ViewStubBinding)1