Edittext in Listview android

后端 未结 6 585
梦如初夏
梦如初夏 2020-12-09 16:05

I have Listview with editext and textview.

When i touch on edittext then edittext lost focus!

I resolved this problem by setting android:windowSoftInpu

6条回答
  •  自闭症患者
    2020-12-09 16:36

    ListView recreate the View, Try to use a LinearLayout inside in ScrollView, then in your code use a runOnUiThread to fill your view in an other thread like this

    public void fillDataTask(Context context, final LinearLayout listView) {
    
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
    
                    fillView(context, listView);
                }
            });
        }
    
    
    
        private void fillView(Context context, LinearLayout listView) {
                MyAdapter adapter = new MyAdapter(context);
                final int adapterCount = adapter.getCount();
                for (int i = 0; i < adapterCount; i++) {
                    View item = adapter.getView(i, null, null);
                    listView.addView(item);
                }
    
        }
    

提交回复
热议问题