I subclassed the standard EditText widget like so
public class MyEditText extends AppCompatEditText {
public MyEditText( Context context )
{
super( context );
}
public MyEditText( Context context, AttributeSet attribute_set )
{
super( context, attribute_set );
}
public MyEditText( Context context, AttributeSet attribute_set, int def_style_attribute )
{
super( context, attribute_set, def_style_attribute );
}
@Override
public boolean onKeyPreIme( int key_code, KeyEvent event )
{
if ( event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP )
this.clearFocus();
return super.onKeyPreIme( key_code, event );
}
}
I declared this widget in my activity xml layout file like so
<MyEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="[enter command here]"
android:textColorHint="#5042f442"
android:textSize="15dp"
android:textColor="#42f442"
android:background="#50000000"
android:layout_alignParentBottom="true"
android:gravity="center|left"
android:paddingLeft="20dp"
android:cursorVisible="false"
/>
</RelativeLayout>
When I install the apk to my phone and run the app I get this error
android.view.InflateException: Binary XML file line #7: Error inflating class MyEditText
Not sure why there is an error inflating the custom Edit Text.
Any idea why?
Thanks