Ad
How Can Concat Two Integers In A TextView Using Databinding?
I have a ViewModel with the next variables:
public MutableLiveData<Integer> questionPosition = new MutableLiveData<>();
public MutableLiveData<Integer> totalQuestions = new MutableLiveData<>();
And I want show it in a TextView like questionPosition/totalQuestions
(this is not a division)
android:text='@={examViewModel.questionPosition + "/" + examViewModel.totalQuestions}'
But in the two cases fail.
How can do it?
Thanks
EDIT
The problem was that I had not to initialize the ViewModel in the Activity, but the code of the question work too.
Ad
Answer
try this:
in String.xml
<string name="output"> %1$s / %2$s </string>
in you xml file
android:text="@{@string/output(examViewModel.questionPosition, examViewModel.totalQuestions)}"
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad