This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TitleItemViewModel { | |
public final ObservableField<String> title = new ObservableField<>(); | |
public TitleItemViewModel() { | |
title.set("Some title"); | |
} | |
public void titleClicked(View view) { | |
title.set("Title clicked"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextView | |
style="@style/Subtitle" | |
android:text="@{viewModel.title}" | |
android:onClick="@{viewModel.titleClicked}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final ObservableField<Boolean> isDataLoading = new ObservableField<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android:visibility="@{viewModel.isDataLoading ? android.view.View.VISIBLE : android.view.View.GONE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final ObservableField<String> countVotes = new ObservableField<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlacesAdapter extends RecyclerView.Adapter<PlacesAdapter.BindingHolder> { | |
private List<PlacesResponseModel.PlaceModel> places; | |
private Activity activity; | |
public PlacesAdapter(Activity activity, List<PlaceModel> places) { | |
this.activity = activity; | |
this.places = places; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<variable | |
name="viewModel" | |
type="com.test.sample.viewmodel.PlaceItemViewModel" /> | |
</data> | |
<LinearLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<variable name="your sample name" type="com.sample.SampleClassName"/> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlaceItemViewModel { | |
private Context context; | |
private PlaceModel placeModel; | |
public PlaceItemViewModel(Context context, PlaceModel placeModel) { | |
this.context = context; | |
this.placeModel = placeModel; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ActivityMainBinding binding; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
binding = DataBindingUtil.setContentView(this, R.layout.activity_main); | |
//tvTitle = TextView in layout with id = tv_title | |
binding.tvTitle.setText("Hello world!"); | |
} |