-7

I want to hide a listview item on release build but make it visible on debug build. I searched it on internet but I can't find anything about it. Anyone can help me?

  • If you are using Android Studio, you can create build flavors in your gradle file which then you can you use in an if statement to set the visibility. – Devsil Jul 24 '17 at 13:55
  • 1
    Welcome to Stack Overflow. Please read first in the help center, how to ask a good question on this forum: https://stackoverflow.com/help/how-to-ask. So we can better unterstand your question and can help you with your problems. – Julian Schmuckli Jul 24 '17 at 13:55
  • Why don't you set the visibility to invisible? – B001ᛦ Jul 24 '17 at 13:56
  • 1. You can use flavor and have different layout for debug and release. 2. You can use BuildConfig.DEBUG flag in if else statements. – Sandeep Shabd Jul 24 '17 at 14:19
  • BuildConfig.DEBUG worked. thanks – user8141097 Jul 24 '17 at 16:59

1 Answers1

5

According to this post, there is an option to detect if an app is in debug or release mode:

if (BuildConfig.DEBUG) {
   lbl.setVisibility(View.VISIBLE);
} else {
   lbl.setVisibility(View.INVISIBLE);
}

Then you simply set the visibility based on the condition to visible or invisible.

Julian Schmuckli
  • 3,681
  • 11
  • 37
  • 64