因此,我一直在尝试这样做,它基本上说我正在尝试获取的“内容”为null。 这是我正在测试的代码(注释部分是我试图使其工作的实际代码,我只是添加了println,以查看获取的数据是否正确,这是不正确的)< / p>
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);
答案 0 :(得分:1)
<DataGrid x:Name="MyDataGrid"/>
<Expander Collapsed="Expander_OnCollapsed"/>
private void Expander_OnCollapsed(object sender, RoutedEventArgs e)
{
MyDataGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
未在该TextView中获取文本。它只显示类名和实例哈希码。您需要使用TextView#toString()
。
使用此:
TextView#getText()#toString()