我有一个屏幕(见照片),有人利用基地Adapter的习俗延伸,用GridView。
当用户进入EditText油田时,他们进入的文字可能会转移或完全消失。 我假定这一点与意见的循环有关,但我对清单编制者的理解不好。
最初,由于Manifest的入境和roid:windowSoftInputMode=“adjustPan”而对这些田地进行了罚款,但如果你ot忙地进行开发,则这些田地将转而去。
All I am looking to do is get some String data from the user. The Strings are stored in a global String array "strings[]". The strings array is updated by MyTextWatcher, which is just an extension of TextWatcher.
The code (attempts) to ensure that the TextWatchers always know the position of their EditText field within the grid. That way, the TextWatchers should always be updating strings[] with the correct index.
我完全有理由相信,这个问题源于我的看法:
public void initList()
{
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, R.layout.shape, strings)
{
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null || convertView.getTag() == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.shape, null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.shape_text);
holder.image = (ImageView) convertView.findViewById(R.id.shape_image);
holder.editText = (EditText) convertView.findViewById(R.id.shape_edittext);
holder.editText.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2){}
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (gameType == SHAPES_ABSTRACT && before == 0 && count == 1) {
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(holder.editText.getWindowToken(), 0);
}
}
public void afterTextChanged(Editable s) {
strings[holder.ref]= s.toString();
}
});
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.ref = position;
holder.editText.setText(strings[position]);
holder.image.setBackgroundResource(images[position]);
if (gameType == SHAPES_ABSTRACT)
holder.text.setText("Seq:");
else
holder.text.setVisibility(View.GONE);
return convertView;
}
};
grid.setAdapter(listAdapter);
}