使用 NS 风格的 Typescript 我想设置一些自动完成的键盘类型。在一个上,我只需要数字,但没有在组件或其“android”对象上找到任何“setInputType”方法或“keyboardType”属性。 RadAutocompleteTextView 扩展了 View 对象,仍然没有这样的元素。
如何设置键盘类型?
尝试使用“android”对象
import { RadAutoCompleteTextView } from "@nativescript/ui-autocomplete";
// ...
public onRadAutoCompleteTextViewLoaded(args) {
const autoCompleteTextView: RadAutoCompleteTextView = args.object;
autoCompleteTextView.android.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
}
尝试使用“editText”
import { AutoCompleteEventData, RadAutoCompleteTextView } from "@nativescript/ui-autocomplete";
import { TextView } from "@nativescript/core/ui/text-view";
function onRadAutoCompleteTextViewLoaded(args) {
const autoCompleteTextView: RadAutoCompleteTextView = args.object;
const nativeEditText: android.widget.EditText = autoCompleteTextView.android;
nativeEditText.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
}
这两种情况,都没有“setInputType”方法。