Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myapplication;
- import android.content.Context;
- import android.os.Looper;
- import android.text.Editable;
- import android.text.SpannableStringBuilder;
- import android.util.AttributeSet;
- import androidx.appcompat.widget.AppCompatEditText;
- public class SDKEditText extends AppCompatEditText {
- SDKEditText(Context context) {
- super(context);
- }
- SDKEditText(Context context, AttributeSet attributeSet) {
- super(context, attributeSet);
- }
- SDKEditText(Context context, AttributeSet attributeSet, int defStyleAttr) {
- super(context, attributeSet, defStyleAttr);
- }
- @Override
- public Editable getText() {
- return new SpannableStringBuilder();
- }
- protected CharSequence getTextInternal() {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- return super.getText();
- }
- return null;
- }
- }
- <com.example.myapplication.SDKEditText
- android:id="@+id/editText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:gravity="center"
- android:inputType="number"
- />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement