- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我一直在尝试这样做,它基本上表明我试图获取的“内容”为空。这是我正在测试的代码(注释部分是我试图让它工作的实际代码,我刚刚添加了 println 以查看获取的数据是否正确,但事实并非如此)
public void FiltarBusqueda(String filtro) {
int count=0;
for (int r = 0; r < mTableLayout.getChildCount(); r++) {
TableRow trow = (TableRow) mTableLayout.getChildAt(r);
for(int c=0;c <= trow.getChildCount();c++){
System.out.println(""+trow.getChildAt(c));
/*if (trow.getChildAt(c).toString() != filtro) {
count++; }
if(count==3){
mTableLayout.removeView(trow); }*/
}
}
}
public void onClickFiltro(View v){
EditText filtro = (EditText)findViewById(R.id.txtproducto);
FiltarBusqueda(filtro.getText().toString());
}
*为每个创建表行的东西也属于同一个类*LinearLayout 的东西:
final LinearLayout layCustomer = new LinearLayout(this);
layCustomer.setOrientation(LinearLayout.VERTICAL);
layCustomer.setPadding(0, 10, 0, 10);
layCustomer.setBackgroundColor(Color.parseColor("#f8f8f8"));
final TextView tv3 = new TextView(this);
if (i == -1) {
tv3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.MATCH_PARENT));
tv3.setPadding(5, 5, 0, 5);
tv3.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallTextSize);
} else {
tv3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.MATCH_PARENT));
tv3.setPadding(5, 0, 0, 5);
tv3.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
tv3.setGravity(Gravity.TOP);
if (i == -1) {
tv3.setText("Productos");
tv3.setBackgroundColor(Color.parseColor("#f0f0f0"));
} else {
tv3.setBackgroundColor(Color.parseColor("#f8f8f8"));
tv3.setTextColor(Color.parseColor("#000000"));
tv3.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallTextSize);
tv3.setText(row.productName);
}
layCustomer.addView(tv3);
最佳答案
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);
}
}
}
关于java - 如何将(代码生成的)TableRow 的内容与字符串进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53108216/
我正在开始使用 mongodb。 我已经设置了所有的 mongodb 和 mongoose 配置,它们工作得很好。 以下是项目文件: server.js: const TableRow = requi
我正在开发 Android 应用程序。一个 Activity 有一个像这样的 TableLayout:
我非常接近选择 LinearLayout 替代方案,但没有正确处理这件事有点令人恼火。为了获得最大的灵 active ,我定义了一个只定义了行标题的 TableLayout xml。接下来,我生成了一
我正在将大量书面内容转换为 Android 应用程序上易于阅读的页面。此内容主要由文本和图像组成,但也包括表格。 内容下载为 html,因此我使用 Html.fromHtml() 方法和 URLIma
我正在尝试将 TableRows 添加到 TableLayout,效果非常好。但是,我在布局参数方面遇到了一些问题。 TableRow 中 TextView 之间的间距与我想象的不一样。 我当前的代码
好的,所以我尝试在每次点击按钮时以编程方式将 TableRows 插入到 TableLayout 中。这些行中的每一行都包含一个设置为某个字符串的 TextView。我的问题是,虽然 TableRow
我是新手,很难达到我要求的输出。代码://这段代码在ScrollView里面 Java 代码: setContentView(R.layout.status_view
我在处理 TableRow 显示时发现问题请给我适当的解决方案 在我的 Java 文件中 tr1 = (TableRow)findViewById(R.id.facebook_raw); tr
我有一个包含 3 个 TableRow 的 TableLayout,每个 TableRow 有 3 个 ImageView。每个 ImageView 都有适合比例类型的 fitCenter,以及每个计
所以,我在一个 xml 文件中有一个 TableLayout 和 4 个 TableRow。我还有一个定义 TextView 的 xml 文件,它将插入行中(每行 3 个 TextView)。我希望那
我的布局是这样的:
我有一个 TableLayout,我在其中动态添加行,一开始是空的,我想在用户单击它时在该行中加载一个 xml。 我已经给行赋值了OnClick方法,但是不知道在onclick方法中进入时如何加载xm
如何在 android TableRow 中获取第一列值并将该值传递给下一个 Activity ?例如,在我的 android Activity 中,我有一个 TableRow,每行有 3 列(节点
我正在尝试使用 TableLayout 制作复杂的网格。我设法通过这样的 xml 来实现(网格中的某些框未突出显示): 通过这段代码:
我正在动态生成 TableRow。对于每个 TableRow,一列中有一个 TextView,另一列中有一个 EditText。如何生成行,使 TextView 占据行的一半而 EditText 占据
我有一个 TableRow 和一个 TextView。这是它的 xml。 我想让表格行在触摸按钮时具有淡出效果,反之亦然。我该怎么做? 最佳答案 任何 View(包括 Tabl
我有以下问题跨越动态添加行到 ScrollView 内的 TableLayout。行遵循以下模式: 第 1 行:单元格横跨整个表格 第 2 行:两个单元格 第 3 行:单元格横跨整个表格 ... 第
我正在尝试为 Android 远程控制制作一个 XML 文件。我用过 TableLayout 正如您从屏幕截图中看到的那样,列的大小发生了变化(但所有图像的大小都相同)。问题仅在于那一行。 这是我的代
我当前有以下设置: ' > 这几乎就是我想要编写的代码: function setBGColor() { var table = document.getElemen
我已从源 REST 端点读取 JSON 数据,并将其写入 BigQuery 表。我想让 BigQuery 表属性更具可读性,即。从 src_lat 到 source_latitude 等... 我已经
我是一名优秀的程序员,十分优秀!