Is there a way to allow the user to select text from many `EditText` in a row (which are in the ListView)?

I am trying to use ListView for message history in an IM application that previously used a single WebView to display history, and I am thinking about how to implement text selection.

I see at least one serious problem - it ListViewprocesses the views, so the naive way does not work if the user tries to select text from a large number of elements and scrolls the list far from the beginning of the selection. But, in any case, Android does not allow you to choose to "jump" from one EditTextto another. So, is there a (cool) way to implement such a function? (This is normal if it only works on Android 4.0+.)

My current example consists of the following code:

Adapter:

private class MessagesAdapter extends ArrayAdapter<String> {

    public MessagesAdapter(Context context, List<String> objects) {
        super(context, 0, objects);
    }

    @Override
    public EditText getView(int position, View convertView, ViewGroup parent) {

        final EditText result = (EditText)(convertView == null ?
                LayoutInflater.from(getContext()).inflate(R.layout.message_row, parent, false) :
                convertView);

        result.setText(getItem(position));
        return result;
    }
}

Line layout:

<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:cursorVisible="false"
          android:editable="false"
          android:textIsSelectable="true"/>

I can select the text in one EditText, but not in many at EditTextonce.

+4
source share

All Articles