2

An app uses ExpandableListActivity, and the usage of ExpandableListView is standard based on the document:

<ExpandableListView
    android:id="@id/android:list"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:divider="@android:color/transparent"
    android:dividerHeight="5dip"
    android:layout_marginTop="10dip">
</ExpandableListView>

Android Studio 3.2 has the following warning: enter image description here

How can I get rid of the warning?

Hong
  • 17,643
  • 21
  • 81
  • 142

2 Answers2

1

This is probably a typo. Change it to:

"@android:id/empty"

and

"@android:id/list"

See also https://developer.android.com/reference/android/app/ListActivity

ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or R.id.list if it's in code)

Bevor
  • 8,396
  • 15
  • 77
  • 141
  • Thank you. "@android:id/list" did it. I do not know how to use "@android:id/empty". Should it be used for the same ExpandableListView? – Hong Dec 08 '18 at 19:54
  • @Hong `@id/android:list` is obviously no valid syntax, so I would say yes. – Bevor Dec 09 '18 at 08:07
  • I added @android:id/empty to the same ExpandableListView in addition to "@android:id/list", but got error "Duplicate attribute id". – Hong Dec 09 '18 at 14:52
  • @Hong You can't add two ids to one view. – Bevor Dec 09 '18 at 14:57
  • Probably I misunderstood your answer. What do you mean by " Change it to: "@android:id/empty" and "@android:id/list""? – Hong Dec 09 '18 at 15:25
  • @Hong It means that it is presumably wrong in this example. `android:id="@id/android:list"` should be `android:id="@android:id/list"` – Bevor Dec 09 '18 at 17:55
  • Very sorry for being so slow in understanding you. How should I follow the first part of your answer: "Change it to: "@android:id/empty"" I have done the second part that seems to have solved the problem. – Hong Dec 09 '18 at 19:30
0

I don't know what is ( id="@id/android:list")

give it an normal id ( @+id/androidlist ) and handle it in your code

but if you learn how to work with ExpandableListView I prefer this link tutorial for you ExpandableListView Link

GL sir

Community
  • 1
  • 1
Hassan Badawi
  • 302
  • 1
  • 10
  • Hello, thank you for trying to help. The usage is copied from the official document for ExpandableListActivity as indicated in my original post. Adding "+" does not solve the problem. ExpandableListActivity has been working very well so far, so I do not plan to change it. I just want to get rid of the warning. – Hong Oct 03 '18 at 13:09