0
以下是代码片段。它与XML文件无关。它只是trD(一个childcount())计数器的声明。 与TRD在错误的路线是:无法解析我的变量的符号错误
((TextView)((TableRow)tableC.getChildAt(trD)).getChildAt(0)).setBackgroundColor(Color.LTGRAY);
//这里是它位于:
try {
for(int x=0 ; x<loopCount; x++){
TableRow.LayoutParams params = new TableRow.LayoutParams(headerCellsWidth[x + 1], LayoutParams.MATCH_PARENT);
params.setMargins(2, 2, 0, 0);
//Log.d("Loadrunner", "info[x] " + x + " " + info[x]);
final TextView textViewB = this.bodyTextView(info[x]);
textViewB.setTextColor(0xFF000000);
tableRowForTableD.addView(textViewB, params);
final int trD = tableD.getChildCount();
//*************************************** Clickable cell
tableRowForTableD.setClickable(true);
}
tableRowForTableD.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
index<tableRowForTableD.getChildCount(); ++index) {
for (int itemPos = 0; itemPos < tableRowForTableD.getChildCount(); itemPos++) {
Log.d("Loadrunner", "TableD ViewGroup itemPos " + itemPos + " " + tableRowForTableD.getChildAt(itemPos).toString());
View view = tableRowForTableD.getChildAt(itemPos);
if (view instanceof TextView) {
TextView textView = (TextView) view;
textView.setBackgroundColor(Color.LTGRAY);
}
}
((TextView)((TableRow)tableC.getChildAt(trD)).getChildAt(0)).setBackgroundColor(Color.LTGRAY);
}
});
我有在由于我以前与其他语言的经验次申报的问题。这可能在我目前的知识水平上。我有一个以前的trC代码片断,可以工作。
我必须在这里补充一点,trC是必须的,因为childcount进一步总是返回总行数。
final TableRow tableRowForTableC = new TableRow(this.context);
final TextView textView = this.bodyTextView(loadRecords.getItem());
textView.setTextColor(0xFF000000);
tableRowForTableC.addView(textView, params);
final int trC = tableC.getChildCount();
//*************************************** Clickable cell
tableRowForTableC.setClickable(true);
tableRowForTableC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textView.setBackgroundColor(Color.LTGRAY);
((TextView)((TableRow)tableD.getChildAt(trC)).getChildAt(0)).setBackgroundColor(Color.LTGRAY);
((TextView)((TableRow)tableD.getChildAt(trC)).getChildAt(1)).setBackgroundColor(Color.LTGRAY);
((TextView)((TableRow)tableD.getChildAt(trC)).getChildAt(2)).setBackgroundColor(Color.LTGRAY);
((TextView)((TableRow)tableD.getChildAt(trC)).getChildAt(3)).setBackgroundColor(Color.LTGRAY);
}
});
tableRowForTableC.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(getContext(), "Item row Edit", Toast.LENGTH_SHORT).show();
return true;}
});
return tableRowForTableC;
}
在此先感谢。到目前为止,每个人都有很大的帮助。
你能发布你得到的实际错误吗? –
我想出了我的逻辑设计错误是什么。这篇文章是静音的。我对分心感到非常抱歉。我在for循环之外移动了trD.Childcount(),因为我可以在那里读取增量。我是一个发明者,必须通过公告例行公事来实现我想要实现的目标。我在真空中工作太多。 RANIMAN心理禁闭。 –