Home java EditText does not display input. Entered text becomes visible only after hiding...

EditText does not display input. Entered text becomes visible only after hiding the keyboard

Author

Date

Category

On the screen there are 8 editText. They go up up in order. After transferring the project to another computer, where the latest version of Android Studio is installed, the last two editText has ceased to be displayed when entering. Before transferring to another PC, everything worked fine and there was no problem. I did not change the code in any way.

On the cropped screenshot, it can be seen that the input occurs, but as if under EditText, and the text itself can be seen only after folding the keyboard or switch to another EditText field.

The application has a “dark theme”, but this problem is not related to the change of colors.

xml:

& lt; xml version = "1.0" encoding = "UTF-8"? & gt;
& lt; androidx.constraintlayout.widget.constraintlayout XMLNS: Android = "http://schemas.android.com/apk/res/android"
  XMLNS: App = "http://schemas.android.com/apk/res-auto"
  XMLNS: Tools = "http://schemas.android.com/tools"
  Android: id = "@ + id / constlay"
  Android: layout_width = "Match_Parent"
  Android: layout_height = "Match_Parent" & gt;
  & lt; TextView
    Android: id = "@ + id / pnrasp"
    Android: layout_width = "wrap_content"
    Android: layout_height = "wrap_content"
    Android: layout_marginstart = "132dp"
    Android: layout_marginend = "132dp"
    Android: layout_marginbottom = "500dp"
    Android: Text = "@ String / PNRASP"
    Android: TextAllCaps = "True"
    Android: TextColor = "# 000000"
    Android: TextSize = "20SP"
    App: layout_constraintbottom_tobottomof = "parent"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.5"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_totopof = "parent"
    App: layout_constraintvertical_bias = "0.100000024" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson1pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "15dp"
    Android: Text = "@ String / Lesson1PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    Android: Visibility = "Visible"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / pnrasp" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson2pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson2PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    Android: Visibility = "Visible"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / lesson1pn" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson3pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson3PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / lesson2pn" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson4pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson4PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_tobottomof = "@ + id / lesson3pn" / & gt;
  & lt; TextView 
Android: id = "@ + id / lesson5pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson5PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / lesson4pn" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson6pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson6PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / lesson5pn" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson7pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson7PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    app: layout_constrainttop_tobottomof = "@ + id / lesson6pn" / & gt;
  & lt; TextView
    Android: id = "@ + id / lesson8pn"
    Android: layout_width = "340dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: Text = "@ String / Lesson8PN"
    Android: TextColor = "# 000000"
    Android: TextSize = "30SP"
    App: layout_constraintend_toendof = "parent"
    App: layout_constrainthorizontal_bias = "0.2"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_tobottomof = "@ + id / lesson7pn" / & gt;
  & lt; button
    Android: id = "@ + ID / PnBackButton"
    Android: layout_width = "160dp"
    Android: layout_height = "75dp"
    Android: layout_marginstart = "90dp"
    Android: layout_margintop = "10dp"
    Android: layout_marginend = "90dp"
    Android: layout_marginbottom = "10dp"
    Android: background = "@ Drawable / PN"
    Android: Text = "@ String / Backbuttonpn"
    Android: TextSize = "24SP"
    App: layout_constraintbottom_tobottomof = "parent"
    App: layout_constraintend_toendof = "parent"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_tobottomof = "@ + id / lesson7pn" / & gt;
  & lt; editText
    Android: id = "@ + id / edittext1"
    Android: layout_width = "338dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "15dp"
    Android: EMS = "10"
    Android: Hint = "@ String / Hint1"
    Android: INPUTTYPE = "TextPersonName"
    Android: MaxLength = "25"
    Android: visibility = "Invisible"
    App: layout_constraintbottom_tobottomof = "parent"
    App: layout_constraintend_toendof = "parent"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_tobottomof = "@ + id / pnrasp"
    App: layout_constraintvertical_bias = "0.0" / & gt;
  & lt; editText
    Android: id = "@ + id / edittext2"
    Android: layout_width = "338dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: EMS = "10"
    Android: Hint = "@ String / Hint2"
    Android: INPUTTYPE = "TextPersonName"
    Android: MaxLength = "25"
    Android: visibility = "Invisible"
    App: layout_constraintbottom_tobottomof = "parent"
    App: layout_constraintend_toendof = "parent"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_tobottomof = "@ + id / lesson1pn"
    App: layout_constraintvertical_bias = "0.0" / & gt;
  & lt; editText
    Android: id = "@ + id / edittext3"
    Android: layout_width = "338dp"
    Android: layout_height = "wrap_content"
    Android: layout_margintop = "10dp"
    Android: EMS = "10"
    Android: Hint = "@ String / Hint3"
    Android: INPUTTYPE = "TextPersonName" 
android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson2pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; EditText
    android: id = "@ + id / editText4"
    android: layout_width = "338dp"
    android: layout_height = "wrap_content"
    android: layout_marginTop = "10dp"
    android: ems = "10"
    android: hint = "@ string / hint4"
    android: inputType = "textPersonName"
    android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson3pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; EditText
    android: id = "@ + id / editText5"
    android: layout_width = "338dp"
    android: layout_height = "wrap_content"
    android: layout_marginTop = "10dp"
    android: ems = "10"
    android: hint = "@ string / hint5"
    android: inputType = "textPersonName"
    android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson4pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; EditText
    android: id = "@ + id / editText6"
    android: layout_width = "338dp"
    android: layout_height = "wrap_content"
    android: layout_marginTop = "10dp"
    android: ems = "10"
    android: hint = "@ string / hint6"
    android: inputType = "textPersonName"
    android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson5pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; EditText
    android: id = "@ + id / editText7"
    android: layout_width = "338dp"
    android: layout_height = "wrap_content"
    android: layout_marginTop = "10dp"
    android: ems = "10"
    android: hint = "@ string / hint7"
    android: inputType = "textPersonName"
    android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson6pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; EditText
    android: id = "@ + id / editText8"
    android: layout_width = "338dp"
    android: layout_height = "wrap_content"
    android: layout_marginTop = "10dp"
    android: ems = "10"
    android: hint = "@ string / hint8"
    android: inputType = "textPersonName"
    android: maxLength = "25"
    android: visibility = "invisible"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toBottomOf = "@ + id / lesson7pn"
    app: layout_constraintVertical_bias = "0.0" / & gt;
  & lt; Button
    android: id = "@ + id / showbtntext"
    android: layout_width = "100dp"
    android: layout_height = "wrap_content"
    android: background = "@ drawable / pn"
    android: text = "@ string / showbtntext"
    app: layout_constraintBottom_toBottomOf = "parent"
    app: layout_constraintEnd_toEndOf = "parent"
    app: layout_constraintHorizontal_bias = "0.95"
    app: layout_constraintStart_toStartOf = "parent"
    app: layout_constraintTop_toTopOf = "parent"
    app: layout_constraintVertical_bias = "0.98" / & gt;
  & lt; Button
    android: id = "@ + id / savebtntext"
    android: layout_width = "100dp"
    android: layout_height = "wrap_content"
    android: background = "@ drawable / pn" 
Android: Text = "@ String / SavebtnText"
    Android: visibility = "Invisible"
    App: layout_constraintbottom_tobottomof = "parent"
    App: layout_constraintend_toendof = "parent"
    App: layout_constraintstart_tostartof = "parent"
    App: layout_constrainttop_totopof = "parent"
    App: layout_constraintvertical_bias = "0.98" / & gt;
& lt; /androidx.constraintlayout.widget.constraintlayout>

java:

Public Class PNDay Extends Activity Implements View.onclicklistener {
  Private SoundPool Msound;
  Private SoundPool Msound2;
  Private int mmelody = 1;
  EditText [] EditTexts;
  TextView [] Lessons;
  TextView PNRASP;
  Button SavebtnText, Showbtn, PnBackButton;
  SharedPreferences SPREF;
  int x = 0;
  Constraintlayout Constlay;
  Final String [] SAVED_TEXT = {
      "SAVED_TEXT",
      "SAVED_TEXT2",
      "SAVED_TEXT3",
      "SAVED_TEXT4",
      "SAVED_TEXT5",
      "SAVED_TEXT6",
      "SAVED_TEXT7",
      "SAVED_TEXT8"};
  @Override
  Public Void OnCreate (Bundle SavedInstanceState) {
    Super.ONCREATE (SavedInstanceState);
    setContentView (R.Layout.PNDay);
    Msound = New Soundpool (1, audioManager.stream_music, 0);
    msound.load (this, r.raw.click, 1);
    Msound2 = New Soundpool (1, audioomanager.stream_music, 0);
    msound2.Load (this, r.raw.clicksch, 1);
    // Button output from activity
    PnBackButton = (Button) FindViewByid (R.ID.PNBACCTTON);
    PnBackButton.SetonClicklistener (new view.onclicklistener () {
      @Override
      Public Void OnClick (View V) {
        Try {
          INTENT INTENT = NEW INTENT (PNDAY.THIS, SELECTWEEKDAY.CLASS);
          INTENT.PUTEXTRA ("X", X);
          StartActivity (INTENT); FINISH ();
          AudioManager AudioManager = (AudioManager) GetSystemService (Audio_Service);
          Msound.play (Mmelody, 1,1,1,0,1);
        } Catch (Exception E) {
        }
      }
    });
    editTexts = New EditText [] {
        (EditText) FindViewByid (R.ID.EDITTEXT1),
        (EditText) FindViewByid (R.ID.EDITTEXT2),
        (EditText) FindViewByid (R.ID.EDITTEXT3),
        (EditText) FindViewByid (R.ID.EditText4),
        (EditText) FindViewByid (R.ID.EDITTEXT5),
        (EditText) FindViewByid (R.ID.EDITTEXT6),
        (EditText) FindViewByid (R.ID.EDITTEXT7),
        (EditText) FindViewByID (R.ID.EditText8)};
    Lessons = New TextView [] {
        (TextView) FindViewByid (R.ID.Lesson1PN),
        (TextView) FindViewByid (R.ID.Lesson2PN),
        (TextView) FindViewByid (R.ID.Lesson3PN),
        (TextView) FindViewByid (R.ID.Lesson4PN),
        (TextView) FindViewByid (R.ID.Lesson5PN),
        (TextView) FindViewByid (R.ID.Lesson6PN),
        (TextView) FindViewByid (R.ID.Lesson7PN),
        (TextView) FindViewByid (R.ID.Lesson8PN)};
    // "Set up" button
    showbtn = (button) FindViewByid (R.ID.ShowBtnText);
    showbtn.setonclicklistener (new view.onclicklistener () {
      @Override
      Public Void OnClick (View V) {
        showbtn.setvisibility (view.invisible);
        savebtntext.setvisibility (view.visible);
        For (EditText EDITTEXT: editTexts) {
          EditText.Setvisibility (view.visible);
        }
        For (TextView Lesson: Lessons) {
          Lesson.SetVisibility (view.invisible);
        }
        AudioManager AudioManager = (AudioManager) GetSystemService (Audio_Service);
        msound2.play (Mmelody, 1,1,1,0,1);
      }
    });
    // "Save" Button
    SavebtnText = (Button) FindViewByid (R.ID.SavebtnText);
    SavebtnText.SetonClicklistener (this);
    Constlay = (ConstraintLayout) FindViewByid (R.ID.CONSTLAY);
    PNRASP = (TextView) FindViewByid (R.ID.PNRASP);
    // Dark theme
    Final Bundle Arguments = GetIntent (). GetExtras (); 
x = arguments.getint (x ");
    LoadText ();
    checkX ();
  }
  @Override
  Public Void OnClick (View V) {
    Switch (v.getid ()) {
      Case R.ID.SavebtnText:
        savetext ();
        showbtn.Setvisibility (view.visible);
        savebtntext.setvisibility (view.invisible);
        For (EditText EDITTEXT: editTexts) {
          EditText.SetVisibility (view.invisible);
        }
        For (TextView Lesson: Lessons) {
          Lesson.Setvisibility (view.visible);
        }
        AudioManager AudioManager = (AudioManager) GetSystemService (Audio_Service);
        Msound.play (Mmelody, 1,1,1,0,1);
        LoadText ();
        Break;
      Default:
        Break;
    }
  }
  Void Savetext () {
    SPREF = GetPreferences (Mode_Private);
    Sharedpreferences.Editor ED = spref.edit ();
    For (int i = 0; i & lt; edittexts.length; i ++)
    {
      ED.PutString (SAVED_TEXT [I], EDITTEXTS [I] .GetText (). Tostring ());
    }
    ed.commit ();
  }
  void LoadText () {
    SPREF = GetPreferences (Mode_Private);
    For (int i = 0; i & lt; edittexts.length; i ++)
    {
      STRING SAVEDTEXT = SPREF.GETSTRING (SAVED_TEXT [I], "");
      Lessons [i] .settext (SAVEDTEXT);
      EditTexts [i] .settext (SAVEDTEXT);
    }
  }
  @Override
  Public void onbackpressed () {
    Try {
      INTENT INTENT = NEW INTENT (PNDAY.THIS, SELECTWEEKDAY.CLASS);
      INTENT.PUTEXTRA ("X", X);
      StartActivity (INTENT); FINISH ();
    } Catch (Exception E) {
    } // end of the design
  }
  Void CheckX () {
    if (x == 1) {
      Constlay.SetBackGroundColor (Color.Parsecolor ("# 1F1F1F"));
      PNRASP.SetTextColor (Color.Parsecolor ("# D8D8D8"));
      For (TextView Lesson: Lessons) {
        lesson.settextcolor (Color.Parsecolor ("# D8D8D8"));
      }
      PnBackButton.SetTextColor (Color.Parsecolor ("# D8D8D8"));
      showbtn.settextcolor (Color.Parsecolor ("# D8D8D8"));
      savebtntext.settextcolor (Color.Parsecolor ("# D8D8D8"));
      For (EditText EDITTEXT: editTexts) {
        edittext.sethinttextcolor (Color.Parsecolor ("# AAAAAA"));
        edittext.settextcolor (Color.Parsecolor ("# D8D8D8"));
        editText.getBackGround (). SetColorFilter (Color.White, portterduff.mode.src_atop);
      }
    }
    if (x == 0) {
      Constlay.SetBackGroundColor (Color.Parsecolor ("# FFFFFF"));
      PNRASP.SETTEXTCOLOR (Color.Parsecolor ("# 000000"));
      For (TextView Lesson: Lessons) {
        lesson.settextcolor (Color.Parsecolor ("# 000000"));
      }
      PnBackButton.SetTextColor (Color.Parsecolor ("# 000000"));
      showbtn.settextcolor (Color.Parsecolor (# 000000 "));
      savebtntext.settextcolor (Color.Parsecolor (# 000000 "));
      For (EditText EDITTEXT: editTexts) {
        editText.SethinttextColor (Color.Parsecolor ("# 555555"));
        edittext.settextcolor (Color.Parsecolor (# 000000 "));
        editText.getBackGround (). SetColorFilter (Color.Black, PorterDuff.mode.src_atop);
      }
    }
  }
}

Answer 1, Authority 100%

Found a solution! The problem was in the line from Manifesta Android: hardwareaccelerated = "false"
As she influenced it, I am without a concept. To be honest, he himself would not refuse the explanations of those who understand.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions