The background of the layout does not change programmatically if initialized in the designer

16 views
Skip to first unread message

Александр Страшко

unread,
Oct 10, 2017, 10:39:11 AM10/10/17
to App Inventor Open Source Development
Hello

Discovered this. If the background color of the layout is set to None in the designer then the color changes to yellow with this code

((android.view.View) object.getView()).setBackgroundColor(-256);

 If the background color of the layout is set in the designer to color (not None), then it does not change to yellow! 

But when i use the button, the background color changes to yellow in both cases!

Evan Patton

unread,
Oct 10, 2017, 12:38:24 PM10/10/17
to App Inventor Open Source Development
Where is this code located? Depending on where it is placed I could see that it is forcing the color to be yellow regardless of what you actually specify in the Designer. Note that we do not generate a call to the property setter for the default value, so that may affect your results.

Evan

Александр Страшко

unread,
Oct 10, 2017, 2:25:09 PM10/10/17
to App Inventor Open Source Development
The code is


    @SimpleFunction
    public void PutAppObjectToList(AndroidViewComponent object, String name) {

        String result = "";
       
        if(isUniqueName(name)){
            try{
               

                viewMap.put(name, object.getView());
                result = "Object with name " + name + " is added to the list";
                ((android.view.View) object.getView()).setBackgroundColor(-256);
               
            } catch(Exception e){
               
                result = e.toString();
            }
        }   
       
        logList.add("\t"+result);
    }


вторник, 10 октября 2017 г., 19:38:24 UTC+3 пользователь Evan Patton написал:
Reply all
Reply to author
Forward
0 new messages