Android InputViews → Android AppCompatEditText – Camposha

Android InputViews

Android InputViews

Android AppCompatEditText

Android AppCompatEditText Tutorial and Example.

Creating a Custom EditText

Let’s say we want to create a custom AppCompatEditText called a TextBox.

We will supply a constructorand can override various events as per our wish.

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;

public class TextBox extends android.support.v7.widget.AppCompatEditText
{
    Context context;

    public TextBox(Context context, AttributeSet attributeSet)
    {
        super(context,attributeSet);
        this.context = context;
    }

    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent keyEvent)
    {
        if(keyCode == KeyEvent.KEYCODE_BACK) // if back button is pressed
        {
           GameStandard.instance.finish();
        }
        return false;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

X