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

Android如何在ListView中使EditText可編輯

Android how to make EditText editable inside a ListView(Android如何在ListView中使EditText可編輯)
本文介紹了Android如何在ListView中使EditText可編輯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我有一個 ListView,每個項目中都有編輯文本,我想知道如何使 EditText 可編輯.如果我設(shè)置android:windowSoftInputMode="adjustPan" 進入清單,但僅在某些設(shè)備上.在某些設(shè)備上,軟鍵盤會覆蓋編輯文本.

I have a ListView with edit text in each items and I want to know how can I make the EditText editable.. It seems to work fine if I set the android:windowSoftInputMode="adjustPan" into the manifest but only on some devices. On some devices the soft keyboard covers the edittext.

另一方面,如果我沒有將 android:windowSoftInputMode="adjustPan" 放在清單中,則 EditText 在顯示軟鍵盤后失去焦點并且我必須多次觸摸 EditText 才能將其選中并可以在其中寫入.

On the other side, if I don't put android:windowSoftInputMode="adjustPan" in the manifest, the EditText looses focus after the soft keyboard is displayed and I have to touch the EditText multiple times to make it selected and can write in it.

請幫我解決這個問題.

注意:我看過這篇文章:ListView 內(nèi)的可聚焦 EditText 沒有任何幫助,除此之外我還有其他問題

Note: I've seen this post: Focusable EditText inside ListView and nothing helped from there and I have totally other problem than that

推薦答案

我為此做了一個解決方法..也許會幫助某人

I made a workaround for this though.. maybe will help someone

public class EditTextListAdapter extends BaseAdapter {

    /* notes list */
    private ArrayList<SomeData> mSomeData = null;
    /* layout inflater instance */
    private LayoutInflater mInflater;
    /* activity context */
    private Context mContext;

    /* ensure that this constant is greater than the maximum list size */
    private static final int DEFAULT_ID_VALUE = -1;
    /* used to keep the note edit text row id within the list */
    private int mNoteId = DEFAULT_ID_VALUE;

    /**
     * EditTextListAdapter adapter class constructor
     *
     * @param context               activity context
     */
    public FirstTimesListAdapter(Context context) {

        /* get a layout inflater instance */
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        /* load the data */
        mSomeData = SomeData.instance().getData(); 
        /* keep the context */
        mContext = context;
    }

    /**
     * Returns the selected item
     *
     * @return selected item
     */
    public int getSelectedItem() {
        return mSelectedItem;
    }

    public int getCount() {
        return mSomeData.size();
    }

    public Object getItem(int i) {
        return mSomeData.get(i);
    }

    public long getItemId(int i) {
        return i;
    }

    public View getView(final int index, View recycledView, ViewGroup viewGroup) {

        ViewHolder viewHolder;

        if (recycledView == null) {
            /* inflate the list item */
            recycledView = mInflater.inflate(R.layout.listview_item_with_edit_text, viewGroup, false);
            /* get link to the view holder views */
            viewHolder = new ViewHolder();
            viewHolder.note = (EditText) recycledView.findViewById(R.id.first_times_note);
            recycledView.setTag(viewHolder);
        } else {
            /* reuse the same views we load the first time */
            viewHolder = (ViewHolder) recycledView.getTag();
        }

        /* display some notes */
        viewHolder.note.setText(mSomeData.getNotes());

        /* if the last id is set, the edit text from this list item was pressed */
        if (mNoteId == index) { 

            /* make the edit text recive focus */
            viewHolder.note.requestFocusFromTouch();
            /* make the edit text's cursor to appear at the end of the text */
            viewHolder.note.setSelection(viewHolder.note.getText().length());

            /* reset the last id to default value */
            mNoteId = DEFAULT_ID_VALUE;
        }

        /* set a touch listener on the edit text just to record the index of the edit text that was pressed */
        viewHolder.note.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                    /* get the index of the touched list item */
                    mNoteId = index;
                }
                return false;
            }
        });

        return recycledView;
    }

    static class ViewHolder {        
        /* note input */
        EditText note;
    }

}

這篇關(guān)于Android如何在ListView中使EditText可編輯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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問題)
主站蜘蛛池模板: 99久久九九 | 久久久久久亚洲 | 超碰成人av | 国产一区精品在线观看 | 欧美一区二区视频在线观看 | 婷婷狠狠 | 青草福利视频 | 少妇高潮久久久久久潘金莲 | 成人午夜在线观看 | 午夜激情在线观看 | 国产成人91 | av中文网 | 一本一道久久a久久精品蜜桃 | 日韩免费成人 | 国产精品福利在线 | 国产精品国产三级国产 | 黄色综合网 | 一区二区三区四区视频在线观看 | 亚洲欧美日韩一区二区三区四区 | 天天干女人 | 久久最新网址 | 激情久久av| 韩日视频 | 日韩欧美一区二区三区久久婷婷 | 伊人激情网 | 在线视频黄 | 欧美一级黄色大片 | 黑人一级黄色片 | 夜夜欢天天干 | 99久久精品一区二区成人 | 国产午夜影院 | 黄视频免费观看 | 日本a在线观看 | 少妇视频网站 | 欧美一区二区三区在线视频 | 中日韩毛片 | 国产精品自拍一区 | 日韩一区二区精品 | 六月丁香激情 | 天天射天天操天天干 | 茄子视频色 |