我试图传递给react-native上的ListView组件中的nextResponder(TextInput)。
我找到了解决方案来实现它:React Native: Refs in ListView
但是使用这个我只能切换到下一个textInput,之后当我点击' next'时键盘被解除。
我知道焦点方法有效,而且我看过许多人们有多个TextInput的例子,他们通过使用refs来关注下一个。
我的问题是我的listview的行数是动态的,我无法手动添加所有TextInput。
我尝试使用renderRow方法的sectionID属性,它给出了每行的索引,但我似乎无法连接到下一个TextInput。
有关您的信息,请参阅以下代码:
renderInput(rowData, rowID, sectionID) {
var inputRefs = [];
var _focusInput = function(name) {
inputRefs[name].focus();
};
var index = 0
var input1 =
<TextInput
placeholder={'Enter your input'}
blurOnSubmit={false}
ref={(input) => {
inputRefs[index] = input;
}}
onSubmitEditing={_focusInput.bind(null, index + 1)}
onEndEditing={_focusInput.bind(null, index + 1)} />;
var input2 =
<TextInput
placeholder={'Enter your input'}
blurOnSubmit={false}
ref={(input) => {
inputRefs[index + 1] = input;
}} />;
return (
<View>
{input1}
{input2}
</View>
);
}
我希望一个聪明的头脑可以引导我走向正确的方向!
干杯