1

I am working on an android project and I am making use of jfeinstein sliding menu library, library can be located at https://github.com/jfeinstein10/slidingmenu.

I have got the library working fine and have amended my code to make it work with other components, not just TextViews, such as Switches. I am now trying to add an EditText to the menu so that the user can enter directly in the box without having to switch activities.

I have it so I have a called MenuAdapter which extends ArrayAdapter. This then has a series of constructors which, based on the constructor and what values are passed into, determine which control is added to the sliding menu. The EditText is being added to the sliding menu and the hint is being sent, and when I tap on the edit text the keyboard is displayed but if I type anything, its not shown in the EditText. However, oddly, if I long press on the edit text and click paste, I can view the content that is pasted so its just typing that's not working.

Below is the XML layout, each component is hidden using the visibility set to gone and then is set to be displayed dependent on the constructor that was used.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/row_icon"
        android:paddingLeft="25dp"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:padding="10dp"
        android:visibility="gone" />

    <TextView
        android:id="@+id/row_title"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:text="Medium Text"
        android:textAppearance="@android:style/TextAppearance.Medium"
        android:visibility="gone"
        android:textColor="@color/White" />

    <Switch 
        android:id="@+id/row_switch"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:visibility="gone"
        android:textColor="@color/White"/>

    <EditText 
        android:id="@+id/row_edittext"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:visibility="gone"
        android:textColor="@android:color/white" />

</LinearLayout>

Below is the code for how the EditText is being addd to the menu.

case EDITEXT:
    EditText editText = (EditText)convertView.findViewById(getItem(position).viewID);
    editText.setHint(getItem(position).hint);
        editText.setEnabled(true);
    editText.setVisibility(View.VISIBLE);
        break;

Thanks for any help you can provide.

4

0 回答 0