1

I have set button as setpressed() from code and and with help of style xml its colour changed but when minimize the app and reopen it then xml setpressed style resets and again its colour changed to default. please help

2 Answers2

0

You need to set your style & setpressed() (or else set some flag)in onResume() method because when app comes to front from background then onResume method is being called

0

Thanks all.. there were many buttons and i have given id as b_1,b_2.... in below code I set them as setpressed(true) and after minimizing and resuming the same I set them back as setpressed(true) on the basis of setPaintFlags value.

android code:

String buttonID = "b_" + no ;
        int resID = getResources().getIdentifier(buttonID, "id", "com.sanjaypatil.housie");
        abc = ((Button) findViewById(resID));
        abc.setPressed(true);
        abc.setPaintFlags(1);

public void onResume()
    {
        super.onResume();
        String t;
        for(int l=1; l<=90; l++){
            t = "b_" + l;
            int resID2 = getResources().getIdentifier(t, "id", "com.abc.efg");
            abc2 = ((Button) findViewById(resID2));
            int flag = abc2.getPaintFlags();
            if(flag==1)
            {
                abc2.setPressed(true);
            }
        }


    }