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

帶有edittext的列表視圖-在“下一個(gè)"上自動(dòng)滾

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

問題描述

限時(shí)送ChatGPT賬號(hào)..

我有一個(gè) ListView,每行都有一個(gè) EditText(除了幾個(gè)不可編輯的 TextView).當(dāng)我在 EditText 中編輯文本時(shí),軟鍵盤有下一步"按鈕 - 按下它會(huì)將焦點(diǎn)移動(dòng)到下一個(gè)字段 - 這很棒.在最后一行,按鈕變?yōu)橥瓿?.

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 根據(jù)是否為最后一行將按鈕設(shè)置為完成"或下一步".

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

問題是列表視圖可以有更多的行可以適應(yīng)屏幕.發(fā)生這種情況時(shí),在下一個(gè)可見行上按下一步"會(huì)將焦點(diǎn)再次移動(dòng)到第一行.如何讓它滾動(dòng)列表并轉(zhuǎn)到下一行?

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;
    }
}

推薦答案

好的,經(jīng)過長(zhǎng)時(shí)間的努力,我終于找到了適合我的情況的 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;
    }
});

這篇關(guān)于帶有edittext的列表視圖-在“下一個(gè)"上自動(dòng)滾動(dòng)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Cut, copy, paste in android(在android中剪切、復(fù)制、粘貼)
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 位小數(shù)的數(shù)字)
Changing where cursor starts in an expanded EditText(更改光標(biāo)在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: av免费入口 | 国产资源在线观看 | 久久大陆 | 欧美一区二区三区在线看 | 日本免费一区二区三区四区 | 嫩呦国产一区二区三区av | 国产在线精品一区二区三区 | 伊人狠狠 | 国产在线一区二区三区 | 精品久久久久国产 | 国产丝袜一区二区三区免费视频 | 欧美成人免费在线 | 成人免费视频7777777 | 一级毛片免费完整视频 | 亚州综合一区 | 拍戏被cao翻了h承欢 | 伊人久久免费 | 成人在线观看中文字幕 | 九九免费观看视频 | 国产精品久久久久久久久久 | 日本免费网 | 第一福利社区1024 | 91高清免费| 亚洲性在线 | 五月激情综合网 | 九九精品在线 | 日韩福利电影 | 日韩国产精品一区二区三区 | 日韩在线免费播放 | 91资源在线 | 精品永久 | 欧美午夜视频 | 国产成人一区二区三区久久久 | 国产精品日产欧美久久久久 | 18av在线播放 | 福利视频一区二区三区 | 亚洲在线 | 精品福利视频一区二区三区 | 国产欧美精品一区二区 | 日韩综合在线 | 亚洲精品电影在线 |