Custom listview edittext is not editable when a button is clicked when I use descedantsfocusability = "blockdescedant"

public void onClick(View v) {

                        linearparent = (LinearLayout) v.getParent(); // first
                        // parent

                        linearparent.setFocusable(true);

                        top_parent = (RelativeLayout) linearparent
                                .getParent(); // top parent

                        gateway_list_name_edit_text = (EditText) top_parent
                                .findViewById(R.id.gateway_list_name_text_view_temp);

                        if (v.getTag() == null) {
                            v.setTag(true);
                            v.setBackgroundResource(R.drawable.on);

//top_parent.setDescendantFocusability(ViewGroup.FOCUSABLES_TOUCH_MODE); // edit text gateway_list_name_edit_text .setBackgroundResource (android.R.drawable.editbox_background);

                            gateway_list_name_edit_text
                                    .setTextColor(Color.BLACK);
                            gateway_list_name_edit_text
                                    .setCursorVisible(true);
                            gateway_list_name_edit_text.setFocusable(true);
                            gateway_list_name_edit_text.requestFocus();
                            // gateway_list_name_edit_text.setText("hello");
                            gateway_list_name_edit_text.setEnabled(true);

                        } else {
                            v.setBackgroundResource(R.drawable.white_info);
                            v.setTag(null);
                            top_parent
                                    .setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
                            // make edit text like textview
                            gateway_list_name_edit_text
                                    .setBackgroundColor(Color.TRANSPARENT);

                            gateway_list_name_edit_text
                                    .setTextColor(Color.WHITE);

                        }

                        // notifyDataSetChanged();
                    }

                });
+4
source share

Source: https://habr.com/ru/post/1527824/


All Articles