-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?

5
  • 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
    Commented Jul 24, 2017 at 13:55
  • 1
    Welcome to Stack Overflow. Please read first in the help center, how to ask a good question on this forum: stackoverflow.com/help/how-to-ask. So we can better unterstand your question and can help you with your problems.
    – Julian
    Commented Jul 24, 2017 at 13:55
  • Why don't you set the visibility to invisible?
    – B001ᛦ
    Commented Jul 24, 2017 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. Commented Jul 24, 2017 at 14:19
  • BuildConfig.DEBUG worked. thanks Commented Jul 24, 2017 at 16:59

1 Answer 1

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.

1
  • This worked for me. Thanks... Commented Jul 24, 2017 at 16:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.