5

I'm trying to reuse the 'android:inputType' attribute from TextView in my custom view, but the error I get is:

String types not allowed (at 'inputType' with value 'textMultiline').

I have referred to the solution at https://stackoverflow.com/a/10361617/313042

The attr file contains:

<declare-styleable name="MyEditText">
    <attr name="android:inputType"/>
</declare-styleable>

The MyEditText.java is:

int n = typedArray.getIndexCount();
for (int i = 0; i < n; i++) {
    int attr = typedArray.getIndex(i);

    switch (attr) {
        case R.styleable.MyEditText_android_inputType:
            inputTypes = typedArray.getInt(attr, EditorInfo.TYPE_NULL);
            break;

    }
}

and the layout file contains:

<com.example.MyEditText
  android:id="@+id/met"
  style="@style/MyStyle"
  android:layout_marginLeft="0dp"
  android:layout_marginRight="0dp"
  android:layout_marginTop="12dp"
  android:inputType="textMultiline" />

Is there any way I can solve this issue? Thanks.

Community
  • 1
  • 1
Rajath
  • 11,787
  • 7
  • 48
  • 62

1 Answers1

4

Your typo textMultiline must be textMultiLine.

Please see supported android:inputType via xml in this link

NamNH
  • 1,752
  • 1
  • 15
  • 37
  • That worked perfectly. Thank you. Would have taken a long time to figure this one out. – Rajath Mar 08 '17 at 04:23
  • Yeah. Sometime, I thought how beautiful it is if IDE can support us to detect typo (just kidding). – NamNH Mar 08 '17 at 04:29
  • 2
    Well, it's not such a bad idea - Google can introduce a warning for this - something like "Did you mean textMultiLine?" built into Android Studio. – Rajath Mar 08 '17 at 04:34