1

I have a ListActivity that has list item with EditText in them.

When there is many items on the list (say ~25) and only 7 is visible at a given time. When I tap on one item, I want the keyboard to show "Next" and scroll through 1 - 25. But what ends up happening is, I will get "Next" until 6th item and I get "Done" on the 7th Item. So, essentially just shows that on Visible rows only. Note: I get "Next" automatically without setting imeoption, if I were to set "inputType" on the editText (may be its a bug or a feature :))

Here is what I have done in the AndroidManifest.xml, so the view adjusts to show the cursor and auto scroll the list.

<activity
        ...
        android:windowSoftInputMode="adjustUnspecified|adjustPan">

In the Activity onCreate I set Focusable to false so that editText gets focus instead of listview itself.

ListView listView = getListView();
listView.setFocusable(false);

In the adapter class I set inputType of editText. Doing this gives me "Next" instead of "Enter".

EditText editText = (EditText) view.findViewById(R.id.data_text);
editText.setText(getItem(position));
editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

I have searched through "SO" and google, I have not yet found any leads.

EDIT: Here is my adapter class

class ItemAdapter extends ArrayAdapter<String> {

    public ItemAdapter(Context context, int resource) {
        super(context, resource);
    }

    @Override
    public View getView(final int position, View convertView, final ViewGroup parent) {
        View view = convertView;

        if (view == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(LAYOUT_INFLATER_SERVICE);
            view = layoutInflater.inflate(R.layout.list_item, parent, false);
        }

        final EditText editText = (EditText) view.findViewById(R.id.input_text );
        String data = getItem(position);
        editText.setText(data);

        editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

        return view;
    }
}
  • This is dependent on your onClick method for your button for the most part, maybe influenced by the design of your adapter. – zgc7009 Oct 09 '14 at 16:04
  • Let the listview scroll up an item at 'Next' so the EditText that is 'under edit' is always in the middle of the screen. – greenapps Oct 09 '14 at 20:53
  • Just to clarify, the issue is that, when I have edittext with imeoption of Next in a listview, it is scrolling through only visible rows. So, if I have 25 items, when the app starts the list view will display 1 through 7, ( I would have to fling to see more data.. 7-14.. so on). Issue is that when I stat the app with list displaying 1-7, on the keyboard if I hit "Next", it scrolls to item 2, then 3.. but at 7 if i hit Next, it goes back to 1 instead of going to 8. – user3357771 Oct 09 '14 at 21:00
  • You might want to try this: http://stackoverflow.com/questions/21935312/listview-with-edittext-auto-scroll-on-next – bond Oct 10 '14 at 03:06

1 Answers1

0

Try to set android:imeOptions="actionNext" in your EditText.

Sam Chen
  • 7,597
  • 2
  • 40
  • 73