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

Android如何在ListView中使EditText可編輯

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

問題描述

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

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

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 在顯示軟鍵盤后失去焦點(diǎn)并且我必須多次觸摸 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.

請(qǐng)幫我解決這個(gè)問題.

注意:我看過這篇文章: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

推薦答案

我為此做了一個(gè)解決方法..也許會(huì)幫助某人

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可編輯的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nè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問題)
主站蜘蛛池模板: 日日碰碰 | 精品国产一二三区 | www四虎com | yiren22 亚洲综合 | 国产精品欧美一区二区 | 五月激情综合 | 亚洲精品一区二区在线观看 | 日韩图区| 欧美日韩一区二区三区四区 | www.久久99 | 一级a爱片久久毛片 | 91视频进入 | www.久| 日本激情视频在线播放 | www.99re| 欧美视频第二页 | 亚洲精品视频一区二区三区 | 欧美中文在线 | 亚洲瑟瑟| www.97国产| 国产情侣激情 | 久久精品亚洲国产奇米99 | 日韩亚洲视频 | 日本欧美在线观看视频 | 亚洲福利在线观看 | 91精品久久久久久综合五月天 | 日日久 | a在线观看| 欧美精品在线一区 | 国产美女h视频 | 精品综合网 | 热久久999 | 二区在线视频 | 九九国产 | 久久av一区 | 国产视频一区二区在线观看 | 91天堂网| 午夜精品久久久久久久久久久久 | 久久九九99 | 91麻豆精品国产91久久久更新资源速度超快 | 中国大陆高清aⅴ毛片 |