1
TextInputが押されているときにdatepickerモーダルを表示できるかどうかは疑問です。React NativeがTextInputのDatepickerを表示しない
私はTouchableWithoutFeedback
とTextInput
を使用しています。 Text
を使用するとうまく動作しますが、TextInputを使用すると、datepickerモーダルが表示されません。
TextInputを使用している理由は、underlineColorAndroid
propを使用したいからです。ここで
は目的は私が/ TextInput
をクリックして押したときに、それはDatePickerのモーダルアップをポップし、その後、私は、モーダルから日付を選択することができているコード
showPicker = async (stateKey, options) => {
try {
const newState = {};
const { action, year, month, day } = await DatePickerAndroid.open(options);
if (action === DatePickerAndroid.dismissedAction) {
newState[stateKey + 'Text'] = 'dismissed';
} else {
const date = new Date(year, month, day);
newState[stateKey + 'Text'] = date.toLocaleDateString();
newState[stateKey + 'Date'] = date;
}
this.setState(newState);
} catch ({ code, message }) {
console.warn(`Error in example '${stateKey}': `, message);
}
};
<TouchableWithoutFeedback
onPress={this.showPicker.bind(this, 'simple', { date: this.state.simpleDate })}
>
<TextInput
placeholder="Where the event held*"
onFocus={() => this.onFocus()}
onFocus={() => this.onFocus()}
style={{
height: 60, backgroundColor: this.state.backgroundColor, color: this.state.color
}}
value={this.state.simpleText}
/>
</TouchableWithoutFeedback>
です。
こんにちは、ありがとう、それは動作しますが、テキスト入力はまだ編集可能ですが、私は編集可能にfalseを設定しようとしましたが、showPicker関数はトリガーされませんでした。 – Webster
こんにちは、 'dismissKeyboard'から 'DismissKeyboard 'をインポートしようとすると、' on '' props'で 'DismissKeyboard()'関数を呼び出すことができます。 –
大丈夫よ、あなたは私の一日を救った。ありがとう!! – Webster