Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package com.example.myapplication;
  2.  
  3. import android.content.Context;
  4. import android.os.Looper;
  5. import android.text.Editable;
  6. import android.text.SpannableStringBuilder;
  7. import android.util.AttributeSet;
  8.  
  9. import androidx.appcompat.widget.AppCompatEditText;
  10.  
  11. public class SDKEditText extends AppCompatEditText {
  12. SDKEditText(Context context) {
  13. super(context);
  14. }
  15.  
  16. SDKEditText(Context context, AttributeSet attributeSet) {
  17. super(context, attributeSet);
  18. }
  19.  
  20. SDKEditText(Context context, AttributeSet attributeSet, int defStyleAttr) {
  21. super(context, attributeSet, defStyleAttr);
  22. }
  23.  
  24. @Override
  25. public Editable getText() {
  26. return new SpannableStringBuilder();
  27. }
  28.  
  29. protected CharSequence getTextInternal() {
  30. if (Looper.myLooper() == Looper.getMainLooper()) {
  31. return super.getText();
  32. }
  33. return null;
  34. }
  35. }
  36.  
  37. <com.example.myapplication.SDKEditText
  38. android:id="@+id/editText"
  39. android:layout_width="match_parent"
  40. android:layout_height="wrap_content"
  41. android:layout_marginLeft="10dp"
  42. android:layout_marginRight="10dp"
  43. android:gravity="center"
  44. android:inputType="number"
  45. />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement