1 回答
TA贡献1780条经验 获得超5个赞
TextView#toString()不会在该 TextView 中获取文本。它只打印类名和实例哈希码。您需要使用TextView#getText()#toString().
用这个:
public void FiltarBusqueda(String filtro) {
for (int r = 0; r < mTableLayout.getChildCount(); r++) {
TableRow trow = (TableRow) mTableLayout.getChildAt(r);
boolean hasMatch = false;
for (int c = 0; c <= trow.getChildCount(); c++) {
String text = ((TextView) trow.getChildAt(c)).getText().toString();
hasMatch = text.equals(filtro); //when comparing Strings, use `equals()` not `==`
if (hasMatch) break;
}
if (!hasMatch) {
mTableLayout.removeRow(trow);
}
}
}
添加回答
举报
