How to Hide an Item in Android ListView

The Android SDK ListView item creates a list of values that display on your Android app's screen. ListViews require a list of items you program in the XML code for the Java app. To hide a ListView item without deleting the code, you comment out the line time in the XML code. You use this feature when you want to hide an item that does not function properly, and you do not want the user to see the item in the app without deleting the code.

Instructions

    • 1

      Open the Java coding editor on your desktop. Open the Android app project to load all of the code files in the editor. Double-click the XML file in the "resource" directory to view the code.

    • 2

      Locate the ListView item you want to hide. The following code is an example of a list of color items used in a ListView:

      <resources>
      <string-array name="colors">
      <item>Blue</item>
      <item>Red</item>
      </string-array>
      </resources>

    • 3

      Hide one of the ListView items. For instance, the following code hides the "Blue" color from the list without deleting its code:

      <resources>
      <string-array name="colors">
      <!-- <item>Blue</item> -->
      <item>Red</item>
      </string-array>
      </resources>

      The characters shown before and after the "Blue" item are the "comments" characters. This means the item is still there, but it is hidden from view in the app until you remove those characters.

Related Searches:

References

Comments

Related Ads

Featured