Getting selected label of a select one spinner ODK - odk

I am a little stuck in displaying the selected label of a select one spinner item in another question that follows after selecting the item from the spinner. I can show the selected value of the selected item but I can't show the label of the spinner. For eg.
<itext>
<translation lang="eng">
<text id="/data/HVDC:label">
<value>1.1.5 गा.वि.स</value>
</text>
<text id="/data/HVDC:option0">
<value>वागेश्वरी</value>
</text>
<text id="/data/HVDC:option1">
<value>बनकटवा</value>
</text>
.............
<select1 appearance="minimal" ref="/data/HVDC">
<label ref="jr:itext('/data/HVDC:label')"/>
<item>
<label ref="jr:itext('/data/HVDC:option0')"/>
<value>Bageswari</value>
</item>
<item>
<label ref="jr:itext('/data/HVDC:option1')"/>
<value>Bankatawa</value>
</item>
</select1>
I want to show sth. like "In वागेश्वरी VDC, how many children...." in the next question when i select the first item from the spinner. I was wondering if this was possible. Please show me a direction of how to go about it.
Tried posting in ODK forums but have not heard anything from anyone yet. Any help or guidance is highly appreciated

Related

Accessibility with TouchableOpacity in RN (Nested)

I was wondering if anyone has worked with this issue before.
Issue: I have a Custom Pressable Card Component (Wrapped over a TouchableOpacity) which would had other Views and Texts components along with another nested Touchable Opacity. The UI works for except when using VoiceOver.
What ends up happening is that the accessibility label on the parent takes over and the nested Text and View are merged together along with the button making it hard for blind users to distinguish the nested button.
I think it may be a design issue but wondering if there is a way of working around this.
using this photo as an example .
<TouchableOpacity accessibilityLabel= "User Profile Card">
<Image accessibilityLabel= "User Profile Photo" />
<Text>Beverly Little </Text>
<Text>Javascript Developer</Text>
<Text>Lorem Ipsum dolor sit amet....</Text>
</TouchableOpacity>

TextArea inside padding and new Line in React Native

i'm trying to make inside padding of textarea but can't do it. another poeblem is inside textarea when i start writing something it always go a single long long line doesn't make new line. Can anyone there who can help me by letting me know the two properties?
I have attached a screenshoot left one is given design and right one is i've made.
set multilne to true
<TextInput multiline={true} />
and for padding, set style={{padding: 10}}, like this
<TextInput multiline={true} style={{padding: 10}} />
Also write textAlignVertical="top" otherwise the placeholder will be positioned in the center, finally write like this
<TextInput multiline={true} style={{padding: 10}} textAlignVertical="top" />
Working Example

React native: how to generate blank whitespace that has the same size as a component which will later be rendered?

This is from a Udacity flashcard project. Say I have this screen:
A "Next card" button appears conditionally upon the user hitting "Correct" or "Incorrect" (a value gets set in component state and the button is rendered conditional on that value being true):
All of this content is inside a <View> with alignItems: 'center' and justifyContent: 'center', so when the button appears, everything shifts slightly along the vertical axis.
I'd like to create some kind of "blank" placeholder that will have the exact same size as the "Next card" button and have it "render" before the Correct/Incorrect button is hit, so that this shift does not occur.
I recognize I could set a hard height/width on the button and make some kind of placeholder item with the same size, but this is a general question and I'd like to leave appearance to device defaults as much as possible.
Is this possible, and/or a sensible approach? If not, why not, and what would you suggest instead?
Thank you!
I assume you're doing something like this to render the Next Card button.
{this.state.answerSubmitted && (
<TouchableOpacity>
<Text>Next Card</Text>
</TouchableOpacity>
)}
Instead, you could do something like this, your button will be there, just not visible and clickable.
<TouchableOpacity
disabled={!this.state.answerSubmitted}
style={{opacity: this.state.answerSubmitted ? 1 : 0}}
>
<Text>Next Card</Text>
</TouchableOpacity>
If you already have a style for the button, you can use the array notation.
style={[styles.yourStyle, {opacity: this.state.answerSubmitted ? 1 : 0}]}

Button On press is working only on certain areas of the button in React Native

Hi Everyone,
I am fetching a few buttons from an API and displaying them in a view according to their names. Each of them is displayed as
<TouchableHighlight style={styles.button} onPress={this.onBtnClick.bind(this, item.apiurl)} >
<Text style={styles.Text}{item.displayName}</Text>
</TouchableHighlight>
The button click is not working all over the button except for the last one. It only works on specific areas. I have modified UI is several ways for the first few and checked. It still remains the same.
Any suggestions/Improvements are appreciated.
It's because you're binding the onBtnClick function everytime you click your button.
Simple fix would be onPress={() => this.onBtnClick(item.apiurl)

Combining tap to dismiss keyboard, keyboard avoiding view, and submit button

I have a screen that has a large image with a text input and a button at the bottom. This screen essentially has three requirements:
When the user taps into the input, the input and button should be visible above the keyboard
The user should be able to tap the button to submit the text input
If the user taps anywhere outside of the input (including the button) the keyboard should be dismissed.
I've tried various solutions including using react-native-keyboard-aware-scroll-view but none of them work quite right. This particular library seems to eat taps, so you can't submit on the button press. Otherwise it's good.
The closest I've been able to come is by surrounding various screen elements with <TouchableWithoutFeedback onPress={Keyboard.dismiss}>. When I try to wrap the entire screen contents in <TouchableWithoutFeedback>, <KeyboardAvoidingView> stops working.
<KeyboardAvoidingView behavior="padding">
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<Image source={require('./img.png')} />
</TouchableWithoutFeedback>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View>
{error}
<Text>Search</Text>
<TextInput
value={this.state.search}
onChange={this.handleChange}
/>
<TouchableHighlight onPress={this.handleSubmit}>
<Text>SEARCH</Text>
</TouchableHighlight>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
This is the closest to a working solution, but it still has several problems. First of all, there doesn't seem to be way to add any additional height to KeyboardAvoidingView, so in some cases the button doesn't show above the keyboard. Second, in some cases if the screen is too tall the area underneath the button won't dismiss the keyboard on tap because there's nowhere to put a <TouchableWithoutFeedback> to hide it.
Is there a better way to display things to the user while the keyboard is up while allowing them to tap to dismiss the keyboard and still interact with some controls?
well I was able to solve this by adding
<KeyboardAwareScrollView
ref="scroller"
keyboardShouldPersistTaps={true}
>

Resources