EditText inside ExpandableListView widget
<p>I'm using an ExpandableListView widget. Each group view displays a question. Each question has several child views, which are answers to the question. The final child view contains a button labeled "add answer". When clicked, this button displays an EditText that is in the same view but is initially invisible. </p>

<p>This all works fine and the EditText displays properly when the "add answer" button is clicked. The problem is that, when the user touches the EditText, it causes the view to collapse back to its original state (with the EditText invisible). Interestingly, there are two other buttons in the expanded view, and when they are clicked nothing happens (the view remains expanded and the EditText visible). </p>

<p>Here is the code for the getChildView() method: (addBtn is the name of the button that expands the view to show the EditText)</p>

<pre><code>        @Override
    public View getChildView(int groupPos, int childPos, boolean arg2, View convertView,
            final ViewGroup arg4) {
        //switch (childPos){
        if (childPos == q.get(groupPos).answers.size()){
            convertView = getLayoutInflater().inflate(R.layout.postanswer, null);

            final Button addBtn = (Button)convertView.findViewById(R.id.addAnswerBtn);
            final RelativeLayout clickedBox = (RelativeLayout)convertView.findViewById(R.id.addAnswerClicked);
            final EditText body = (EditText)convertView.findViewById(R.id.addAnswerBody);

            addBtn.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    if (clickedBox.getVisibility() == View.GONE){
                        addBtn.setTextColor(Color.RED);
                        addBtn.setPadding(8, 8, 8, 0);
                        clickedBox.setVisibility(View.VISIBLE);                     
                    }
                    else if (clickedBox.getVisibility() == View.VISIBLE){
                        clickedBox.setVisibility(View.GONE);
                        addBtn.setPadding(8, 8, 8, 8);
                        addBtn.setTextColor(Color.rgb(255, 186, 59));
                    } 
                }
                });
            convertView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    if (clickedBox.getVisibility() == View.VISIBLE){

                    }
                    else if (clickedBox.getVisibility() == View.GONE){
                    }                   
                }               
            });

        }
        else{
        convertView = getLayoutInflater().inflate(R.layout.answerbox, null);        

        final RelativeLayout mainBox = (RelativeLayout)convertView.findViewById(R.id.answerMainBox);
        TextView ansText = (TextView)convertView.findViewById(R.id.answerText);
        TextView ansAuthor = (TextView)convertView.findViewById(R.id.answerAuthor);
        TextView ansUV = (TextView)convertView.findViewById(R.id.answerUpvotes);
        final RelativeLayout clickedBox = (RelativeLayout)convertView.findViewById(R.id.answerClickedBox);

        ansText.setText(q.get(groupPos).answers.get(childPos).text);
        ansAuthor.setText("by " + q.get(groupPos).answers.get(childPos).author);                    
        ansUV.setText(Integer.toString(q.get(groupPos).answers.get(childPos).upvotes));
        convertView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                if (clickedBox.getVisibility() == View.GONE){
                    clickedBox.setVisibility(View.VISIBLE);
                    mainBox.setAlpha((float)0.3);; 
                }
                else if (clickedBox.getVisibility() == View.VISIBLE){
                    clickedBox.setVisibility(View.GONE);
                    mainBox.setAlpha((float)1);; 
                }
            }
            });
        }
        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return q.get(groupPosition).answers.size()+1;
    }
</code></pre>

<p>Here is the xml file for the view containing the EditText:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
</code></pre>

<p></p>

<pre><code>&lt;Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:id = "@+id/addAnswerBtn"
    android:padding="8dip"
    android:gravity = "center_horizontal"
    android:includeFontPadding="false"
    android:layout_centerHorizontal="true"
    android:background="#00000000"
    android:textColor="#FFBA3B"
    android:text = "add an answer"
    android:textAppearance="?android:attr/textAppearanceMedium"&gt;&lt;/Button&gt;

&lt;RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:id = "@+id/addAnswerClicked"
    android:layout_below = "@id/addAnswerBtn"
    android:visibility="gone"&gt;

    &lt;EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#90FFFFFF"
        android:inputType="textMultiLine"
        android:minLines="5"
        android:hint="type your answer here..."
        android:maxLines="10"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:layout_marginBottom="10dip"
        android:id = "@+id/addAnswerBody"
        android:textColor="#000000"
        android:layout_alignParentTop="true"&gt;&lt;/EditText&gt;
    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text = "your name: "
        android:maxLines="1"
        android:paddingLeft="25dip"
        android:id = "@+id/addAnswerName"
        android:layout_below="@id/addAnswerBody"
        android:layout_alignParentLeft="true"&gt;&lt;/TextView&gt;
    &lt;EditText     
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_below = "@id/addAnswerBody"
        android:layout_marginRight="25dip"
        android:background="#90FFFFFF"
        android:layout_toRightOf="@id/addAnswerName"
        android:inputType="text"&gt;&lt;/EditText&gt;
   &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text = "submit"
        android:background="#00000000"
        android:textColor="#3FC451"
        android:paddingTop="5dip"
        android:paddingLeft="40dip"
         android:textAppearance="?android:attr/textAppearanceMedium"
        android:id = "@+id/addAnswerSubmit"
        android:layout_below="@id/addAnswerName"
        android:layout_alignParentLeft = "true"&gt;&lt;/Button&gt;

    &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text = "cancel"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FF0000"
        android:paddingTop="5dip"
        android:paddingRight="40dip"
        android:background="#00000000"
        android:id = "@+id/addAnswerCancel"
        android:layout_below="@id/addAnswerName"
        android:layout_alignParentRight = "true"&gt;&lt;/Button&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p></p>

<p>My apologies, things are a bit of a mess right now as I've tried quite a few different things to solve this problem. Let me know if I need to post any other code.</p>
