1、listview 嵌套EditText 不能获取焦点问题:
解决方案:在adapter适配器中:
EditText etScore=helper.getView(R.id.etScore);
etScore.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_UP) { index = helper.getPosition(); } return false; } }); etScore.clearFocus(); if (index != -1 && index == helper.getPosition()) { // 如果当前的行下标和点击事件中保存的index一致,手动为EditText设置焦点。 etScore.requestFocus(); }
etScore.setTag(item); etScore.setText(score); etScore.setSelection(score.length());2、listView 嵌套 EditText 不能显示焦点://解决光标不显示问题 etScore.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // 关键代码 v.dispatchWindowFocusChanged(hasFocus); } });3、ListView 嵌套EditText 输入法弹出,输入的值变为0:在Activity中设置android:windowSoftInputMode="adjustPan"android:configChanges="keyboardHidden|orientation|screenSize"
本文探讨了在Android开发中遇到的ListView嵌套EditText时无法获取焦点的问题,并提供了具体的解决方案,即在Adapter适配器中进行相应设置。
648

被折叠的 条评论
为什么被折叠?



