久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

帶有edittext的列表視圖-在“下一個"上自動滾

Listview with edittext - auto scroll on quot;nextquot;(帶有edittext的列表視圖-在“下一個上自動滾動)
本文介紹了帶有edittext的列表視圖-在“下一個"上自動滾動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個 ListView,每行都有一個 EditText(除了幾個不可編輯的 TextView).當我在 EditText 中編輯文本時,軟鍵盤有下一步"按鈕 - 按下它會將焦點移動到下一個字段 - 這很棒.在最后一行,按鈕變為完成".

I have a ListView with one EditText on each row (in addition to a couple of non-editable TextView's). When I'm editing the text in the EditText, the soft keyboard has "Next" button - and pressing it moves the focus to the next field - this is great. On the last row, the button changes to "Done".

我正在使用 EditText.setImeOptions 根據是否為最后一行將按鈕設置為完成"或下一步".

I'm using EditText.setImeOptions to set the button to "Done" or "Next" based on whether this is the last row or not.

問題是列表視圖可以有更多的行可以適應屏幕.發生這種情況時,在下一個可見行上按下一步"會將焦點再次移動到第一行.如何讓它滾動列表并轉到下一行?

The problem is that the listview can have more rows that can fit on the screen. When that happens, pressing "Next" on the next visible row moves the focus onto the first row again. How can I make it scroll the list and go to the next row instead?

作為參考,這是我在適配器中所做的:

For reference, here's what I'm doing in my adapter:

public class AuditAdapter extends BaseAdapter {
    private Context context;
    private int layoutResourceId;
    private Audit audit;

    ...

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View row = convertView;
        final AuditItemHolder holder = (row == null ? new AuditItemHolder() : (AuditItemHolder)row.getTag());

        if(row == null)
        {
            LayoutInflater inflater = ...;
            row = inflater.inflate(layoutResourceId, parent, false);
            ...
            holder.qtyf = (EditText)row.findViewById(R.id.item_quantity);
        }

        AuditItem item = audit.getItemAt(position);

        holder.qtyf.setText("" + item.getQuantity());
        holder.qtyf.setImeOptions(position == audit.size() - 1 ? EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_NEXT);

        ...

        row.setTag(holder);
        return row;
    }

    private static class AuditItemHolder {
        ...
        EditText qtyf;
    }
}

推薦答案

好的,經過長時間的努力,我終于找到了適合我的情況的 hack(不是正確的解決方案).在我的適配器的 getView 中,我添加了 onEditorActionListener 并在其中:

Ok, after struggling for a long time, I finally found a hack (not a proper solution) that works for my case. In the getView of my adapter, I add the onEditorActionListener and inside it:

ediField.setOnEditorActionListener(new OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        ListView lv = (ListView)parent;
        if(actionId == EditorInfo.IME_ACTION_NEXT &&
           lv != null &&
           position >= lv.getLastVisiblePosition() &&
           position != audit.size() - 1) {  //audit object holds the data for the adapter
                lv.smoothScrollToPosition(position + 1);
                lv.postDelayed(new Runnable() {
                    public void run() {
                        TextView nextField = (TextView)holderf.qtyf.focusSearch(View.FOCUS_DOWN);
                        if(nextField != null) {
                            nextField.requestFocus();
                        }
                    }
                }, 200);
                return true;
        }
        return false;
    }
});

這篇關于帶有edittext的列表視圖-在“下一個"上自動滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 最新国产视频 | 午夜精品一区二区三区免费视频 | 亚洲成人毛片 | 国产三级网站 | 羞羞的视频免费看 | 亚洲一区二区三区在线视频 | 在线视频成人 | 青青操av | 天天精品在线 | 精品视频久久久久久 | 国产成人网 | 韩国av网站在线观看 | 欧美综合一区二区三区 | 久久久久免费观看 | 成年免费大片黄在线观看一级 | 亚洲高清一区二区三区 | 天天爽夜夜爽精品视频婷婷 | 这里只有精品99re | 韩日中文字幕 | 一区二区三区久久久 | 亚洲视频一区二区三区 | 99热都是精品 | 日韩在线中文 | 亚洲精品中文字幕在线观看 | 精品久久久久久久久久久院品网 | 午夜爱爱网| 久久亚洲欧美日韩精品专区 | 亚洲成年影院 | www.久久久.com | av性色| 91观看 | 一区二区亚洲 | 激情五月婷婷综合 | 在线免费观看a级片 | 日韩中文字幕 | 色又黄又爽网站www久久 | 操操日 | 天天操天天射综合 | 精品欧美一区二区三区 | 欧美在线视频免费 | 可以免费观看的av片 |