I am an iOS developer, and I have been given task to fix this. After digging and googling, I have no idea what to do.
We have this screen:
This screen is Activity with custom Fragment, containing ListView fed by ArrayAdapter. The adapter produces views by getView it seems. Every row has seven EditText controls.
Problem 1: When screen is shown first time, and you tap on any EditText, nothing happens. Why? When you tap second time, and any subsequent time, focus works, keyboard appears, and you can type.
Problem 2: This is hard to describe. On some devices, tapping any EditText causes keyboards to switch between some numeric and alphanumeric types, and this goes on and on and then stops. Why?
After trying various stuff: getExtractedText on inactive InputConnection warning on android onClick event is not triggering | Android Android EditText doesn't show the Keyboard ...
I have no idea what is the problem.
According to one of SO posts, you should not have both onClick and onTouch, yet here they are. Why?
editText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
view.requestFocus();
break;
}
return false;
}
});
editText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((EditText) v).selectAll();
}
});
editText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (event.getAction() == KeyEvent.ACTION_UP) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
return false;
}
});
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
double amount = Double.parseDouble(((EditText)v).getText().toString());
DecimalFormat df = new DecimalFormat("0.0");
String result = df.format(amount);
((EditText)v).setText(result);
}
}
});
}
I am still digging, commenting out various code, but I am in dark, please help.
Whole code: https://gist.github.com/MartinBergerDX/473c47b008b6b0570466794f221eca31
Update 1:
I have removed all listeners, onTouch, onFocus, and text watchers.
And this is still happening:
Update 2:
It seems this is related to keyboard covering ListView. Not sure why, but when I set less than 10 items in data source, keyboard does not cover content and ping pong effect does not happen.