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

Android如何在ListView中使EditText可編輯

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

問題描述

限時送ChatGPT賬號..

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

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 內的可聚焦 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;
    }

}

這篇關于Android如何在ListView中使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問題)
主站蜘蛛池模板: 国产成人精品一区二区 | 国产欧美日韩综合精品一区二区 | 九九导航 | 9191在线观看 | 人人爽人人爽 | 成人在线欧美 | 日韩午夜在线播放 | 精品视频一区二区三区 | 精品三区 | 欧美成人h版在线观看 | 人人艹人人 | 亚洲人成人网 | 亚洲福利网站 | 在线免费亚洲视频 | 亚洲精品国产综合区久久久久久久 | 久久精点视频 | 婷婷精品 | 亚洲黄色国产 | 久久国内精品 | 国产一区亚洲 | 毛片免费在线 | 久久综合色综合 | 日韩欧美在线观看视频网站 | 日本公妇乱淫xxxⅹ 国产在线不卡 | 亚洲啪啪| 日韩一区二区三区在线 | 一级a爱片久久毛片 | 波多野结衣一二三区 | 在线只有精品 | 99精品99| 免费视频99 | 人碰人操| 国产免费一区二区 | 在线播放国产视频 | 可以免费看的毛片 | 在线区| 国产一区二区三区色淫影院 | 久久久久久国产 | 亚洲精品国产电影 | 亚洲第一成人av | 狼人伊人影院 |