The Customize your settings section in the developer guide for settings recommends that you set the input type programmatically by using an OnBindEditTextListener as follows:
public class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.settings_screen, rootKey);
EditTextPreference weeklyGoalPref = findPreference("weekly_goal");
if (weeklyGoalPref != null) {
weeklyGoalPref.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
@Override
public void onBindEditText(@NonNull EditText editText) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
}
});
}
}
}
I tried defining the input type as "number" in xml and still got the normal keyboard with letters. This approach worked for me.