Reputation: 105
I have a warning in an xml file: This TableRow
layout or its TableLayout
parent is possibly useless.
<TableRow android:id="@+id/tableRow2">
...
</TableRow>
I put the attribute android:id
in there, but the warning didn't disappear.
Any ideas as to what may be causing the warning?
Upvotes: 5
Views: 7170
Reputation: 750
The accepted answer is not the best solution, it is terrible practice to ignore warnings. Unless the warning comes from a bug in the compiler or linter itself, eliminating the warning is almost always a better option than ignoring it.
In this case, as the responses to the accepted answer indicate, all you have to do is remove the TableLayout
parent of TableRow
. The warning is most likely there because you have a table with only one row, so the TableLayout
is unnecessary.
E.g. Change this:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow android:id="@+id/tableRow2">
...
</TableRow>
</TableLayout>
To this:
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</TableRow>
Upvotes: 2
Reputation: 4771
Add
tools:ignore="UselessParent"
to your table row to avoid warning or in the tag where you get the warning.
Upvotes: 4