Java 如果删除了编程生成的EditText,如何更新arraylist?

Java 如果删除了编程生成的EditText,如何更新arraylist?,java,android,arraylist,Java,Android,Arraylist,嗨,我一直在做一个项目,我必须做一个加号按钮,然后点击加号按钮a,我正在膨胀一个新的布局,包括两个EditText和一个remove image。 到目前为止,它工作正常,但问题是,当我单击remove image EditText时,该特定行的文本被删除,但数据仍被发送到数据库。 我尝试使用arraylist的remove方法,但仍然不起作用。 所以请有人帮我一下 这是我的布局膨胀代码 public void makedifferentEditText() { try {

嗨,我一直在做一个项目,我必须做一个加号按钮,然后点击加号按钮a,我正在膨胀一个新的布局,包括两个EditText和一个remove image。 到目前为止,它工作正常,但问题是,当我单击remove image EditText时,该特定行的文本被删除,但数据仍被发送到数据库。 我尝试使用arraylist的remove方法,但仍然不起作用。 所以请有人帮我一下

这是我的布局膨胀代码

public void makedifferentEditText() {
        try {

            View secondchild = getLayoutInflater().inflate(R.layout.update_extra_links_layout, null);
            final LinearLayout update_extra_links_layout = (LinearLayout) secondchild.findViewById(R.id.update_extra_links_layout);
            customtextTitle = (CustomEditTextThin) secondchild.findViewById(R.id.google_edit_link);
            customeditTextLink = (CustomEditTextThin) secondchild.findViewById(R.id.facebook_edit_link);
            eexId = (TextView) secondchild.findViewById(R.id.eeid);
            google_tilte.add(customtextTitle);
            google_link.add(customeditTextLink);
            extId.add(eexId);
            Log.e("title", google_tilte.toString());
            Log.e("link", google_link.toString());

            AppCompatImageView removeimage = (AppCompatImageView) secondchild.findViewById(R.id.icon_remove_link);
            rAlign.addView(update_extra_links_layout);
            int indexValue = rAlign.indexOfChild(update_extra_links_layout);
            update_extra_links_layout.setTag(indexValue);

            int ImagePosition = rAlign.indexOfChild(update_extra_links_layout);// update_extra_links_layout.indexOfChild(removeimage);
            removeimage.setTag(ImagePosition);
            removeimage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    try {
                        int index = (int) view.getTag();
                        // if (index != -1) {
                        if (rAlign.getChildCount()>1) {

                            // int index = rAlign.indexOfChild(update_extra_links_layout);
                            rAlign.removeViewAt(index);
                            google_tilte.remove(index);
                            google_link.remove(index);
                            extId.remove(index);
                            //customtextTitle.setText("");
                            //customeditTextLink.setText("");
                        }
                        //}
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
下面是向数据库添加数据的代码

if (google_link != null && google_link.size() > 0) {
                        for (int j = 0; j < google_link.size(); j++) {
                            /*arrayTitle.add(google_link.get(j).getText().toString());
                            Log.e("array", arrayTitle.toString());*/

                            ExtraLinksObject links4 = new ExtraLinksObject();

                            String othergoogleTitle = google_tilte.get(j).getText().toString();//customtextTitle.getText().toString();
                            String othergooglelink = google_link.get(j).getText().toString();//customeditTextLink.getText().toString()
                            String googleId = extId.get(j).getText().toString();//eexId.getText().toString();
                            links4.setLink(othergooglelink);
                            links4.setTitle(othergoogleTitle);
                            links4.setExID(googleId);

                            extraLinks.add(links4);

                        }
                    }
if(google\u link!=null&&google\u link.size()>0){
对于(int j=0;j
为什么不将
回收视图
与适配器一起使用?@Mosius我不知道如何从适配器获取EditText值。因此,如果您想对其进行更多说明,请将Linearlayout添加到父布局中。尝试替换
rAlign.addView(更新额外链接布局)带有
rAlign.addView(第二个子项)它可能work@cooldev您可以为editText设置textChangeListener以更新中的数据list@Suraj我试过了,但还是一样