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:

public class ModuleLayout extends LinearLayout {

public ModuleLayout(Context context, ArrayList<BaseModuleItem> itemList) {
    super(context);
    TableLayout tempTable = new TableLayout(context);

        for (int i = 0; i < itemList.size(); i++)
        {
            TableRow tempRow = new TableRow(context);
            TextView tempTextView = new TextView(context);
            tempTextView.setText(itemList.get(i).getName());

            EditText tempEditText = new EditText(context);
            tempEditText.setText(itemList.get(i).getItemValue());

            tempRow.addView(tempTextView);
            tempRow.addView(tempEditText);

            tempTable.addView(tempRow);
        }

        tempTable.setColumnStretchable(1, true);
        this.addView(tempTable);
    }
}

Here is a picture of the problem in action.

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.

12
задан sonnet 6 December 2017 в 10:27
поделиться