Value in edittext don't show until it get focus. Android

I’m building an app that get its layout based on external data. The layout is split into different blocks depending on the indata. These blocks are displayed with the help of a viewflipper. In each block there is, for the time being, one or more “textview” and “edittext”. On the first page of the flipper all data is showing as it should in the textviews and edittexts. But on the other pages in the viewflipper the value in the edittexts is not showing until the edittext get focused. I have no idea why. So to be clear. The values for all edittexts is actually there, but doesn’t show until the edittext get focused. The problem is the same on all devices I have runned the app on (emulator, HTC Desire, HTC Wildfire). Does anyone know how to fix this problem?

Here is the class that generate the layout:

  • Google Maps API v2: How to make markers clickable?
  • How to make a full screen webview
  • null keyevent and actionid = 0 in onEditorAction() (Jelly Bean / Nexus 7)
  • How can I highlight the table row on click ?
  • AlertDialog with positive button and validating custom EditText
  • Is it safe to save the app context to a static variable in Android?
  • public class ModuleLayout extends LinearLayout {
    public ModuleLayout(Context context, ArrayList<BaseModuleItem> itemList) {
        TableLayout tempTable = new TableLayout(context);
            for (int i = 0; i < itemList.size(); i++)
                TableRow tempRow = new TableRow(context);
                TextView tempTextView = new TextView(context);
                EditText tempEditText = new EditText(context);
            tempTable.setColumnStretchable(1, true);

    Here is a picture of the problem in action. (I don’t have 10 reputation points on stackoverflow so just click the link.)

    The left picture displays all its values fine. The right picture is on the second position in the viewflipper and does not display the values in the edittexts, with the exception for the first that have focus. I should also mention that after an edittext has gotten focus it continues to display the value even if I fling to other views in the viewflipper and then back.

  • GCM msg delivery times are WILDLY erratic
  • DrawerLayout.openDrawer does not work the first time
  • My fragment cannot be cast to
  • SHA-1 fingerprint of keystore certificate
  • How to open a second activity on click of button in android app
  • What is the Simplest Way to Reverse an ArrayList?
  • 2 Solutions collect form web for “Value in edittext don't show until it get focus. Android”

    That Layout from how it appears here is not on the UI thread meaning no matter what you change you won’t see anything until the UI thread (also known as the Main Thread) updates. The UI/Main thread is what all your activities run through so it’s easy to think that stuff just updates automatically (since most of the previous work you have done is also somewhere within the Activity, I am assuming). The onFocusChanged event (clicking in the edittext) will update the UI thread by calling invalidate() on itself. You can force it to update by calling EditText.invalidate() if you need to, but it’s usually best to have it update naturally after creation. Without seeing the rest of your code this is the best I can do for you, I hope this helps 🙂

    Having not seeing your full code I’m making a bit of a guess-suggestion but have you tried textView.invalidate() (if calling from GUI thread) or textView.postInvalidate() (if calling from another thread)?

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.