• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

onActivityResult not updating ui

UziTech

Lurker
Feb 7, 2010
3
0
In my program I have a preference activity that is set to return a result. I dont actually care what the result is i just want to know when it returns.

The code below is the OnActivityResult function. The activity calls the function correctly except when the array of TextViews (F) is set to Invisible they don't disappear. getInvisibility() returns invisible if called right after it is set but if called later it doesn't. If setVisibility(View.INVISIBLE) is called any other time on F in my program it works perfectly.

The code below the for loops is another array of TextViews (L) and that setText works just like it is supposed to.

Is there something wrong with my code or is there another issue with setVisibility() in onActivityResult()?

Code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
        for(int i = 0; i < MAXPLAYERS; i++){
            for(int j = 0; j < 3; j++){
                F[i][j].setVisibility(View.INVISIBLE);
//This does not make the texviews invisible even though F[i][j].getVisibility() will return View.INVISIBLE
            }
        }

        L[0].setText(settings.getString("Player1", getString(R.string.Player1)));//This works perfectly
}
when I changed the code to this it worked

Code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
        for(int i = 0; i < MAXPLAYERS; i++){
            for(int j = 0; j < 3; j++){
                F[i][j].setText("");//This works perfectly but not what I want to do
            }
        }

        L[0].setText(settings.getString("Player1", getString(R.string.Player1)));//This works perfectly
}
but I dont want to change the text I want to make it invisible.

Why does the setText()function work but the setVisibility() function not work?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones