2016-08-18 2 views
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가 필요하다는 것을 추가해야합니다. 그 이유는 하위 카운트가 항상 전체 행 수를 반환하기 때문입니다.

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; 
} 

미리 감사드립니다. 지금까지 모두가 큰 도움이되었습니다.

+0

실제 오류를 게시 할 수 있습니까? –

+0

나는 나의 논리 설계 오류가 무엇인지 알아 냈다. 이 게시물은 음소거입니다. 산만 함을 진심으로 사과드립니다. 나는 거기 증가를 읽을 수 있기 때문에 for 루프 밖에서 trd.Childcount()를 움직였다. 나는 달성하려는 목표를 실현하기 위해 발표 루틴을 거쳐야하는 숙달 된 인물입니다. 나는 진공 상태에서 너무 많이 일한다. RANIMAN 정신 감금. –

답변

0

for 루프 외부에서 trD.Childcount()를 이동했습니다. 그러나 이것은 textws와 함께 tablerows을 추구하는 다른 사람들을위한 것입니다. 다시 불편을 끼쳐 드려 죄송합니다. Java는 C 및 그 변형과 약간 다릅니다.

관련 문제