当我使用descedantsfocusability =“blockdescedant”时,自定义列表视图edittext在按钮单击时不可编辑

时间:2014-02-20 04:21:05

标签: android android-listview

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);                                 //制作编辑文字提名                                 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();
                    }

                });

0 个答案:

没有答案