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);
}
}
}
添加回答
舉報