2014-11-12 4 views
0

동일한 활동에서 같은 텍스트보기와 다른 텍스트를 사용하는 데는 약간의 문제가 있습니다. listGrade라는 조각이 있습니다. 그 onCreateView 방법은 내보기 다른 텍스트 두 개의 텍스트 뷰를 가지고 마지막에 동일한 텍스트보기를 다른 텍스트로 동일한 활동에 사용하십시오.

textViewww.setText(test2);  

View rootView = inflater.inflate(R.layout.fragment_list_grade, container, false);  
TextView textViewww = (TextView) rootView.findViewById(R.id.Number);  
textViewww.setText(test1);  
XML 파일에서 다시 텍스트 뷰를 만들 수 있다는 것입니다 내가 원하는

를 얻을. 어떻게하면됩니까?

fragment_list_grade.xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/llayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<ScrollView 
    android:id="@+id/layout" 
    android:layout_height="wrap_content" 
    android:scrollbars="horizontal|vertical" 
    android:layout_width="match_parent" 
    android:layout_marginTop="5dip" 
    android:scrollbarStyle="outsideInset" 
    android:fillViewport="true"> 

    <HorizontalScrollView 
     android:id="@+id/horizontalView" 
     android:layout_height="wrap_content" 
     android:scrollbars="horizontal|vertical" 
     android:layout_width="wrap_content" 
     android:layout_marginTop="5dip"> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/tableLay" 
      android:background="#ffffff"> 
<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent"> 

    <TextView 
     android:id="@+id/Number" 
     android:text="Row 2 column 1" 
     android:layout_weight="1" 
     android:background="#dcdcdc" 
     android:textColor="#000000" 
     android:padding="20dip" 
     android:gravity="center"/> 

    </TableRow> 
</TableLayout> 
</HorizontalScrollView> 
</ScrollView> 
</LinearLayout> 
+0

당신은 어떤 문제에 직면하고 있습니까 ?? –

+0

웹 서비스에서 알 수없는 텍스트 수가 있기 때문에 이걸 원합니다. 동일한 모양으로 동적으로 textView를 만들어야합니다. – guneraykut

+0

보기에서 textview를 부풀려 야합니다. – duggu

답변

0

1) 새로운 XML 레이아웃을 생성 * /에/* 텍스트보기의 LAYOUT.xml에 텍스트를 넣어.

2), 내가 이해에서 레이아웃

LinearLayout lt = (LinearLayout) findViewById(R.id./*YOUR TEXT VIEW CONTAINER*/); 
    TextView textViewww = (TextView) getLayoutInflater().inflate(R.layout./*YOUR TEXT VIEW LAYOUT.xml*/, null); 
    textViewww.setText(test2); 
    lt.addView(textViewww); 
+0

귀하의 조언을 주셔서 감사합니다 – guneraykut

+0

당신은 오신 것을 환영합니다! – Rami

0

을 팽창 여러 TextViews을해야합니다 그리고 당신은 웹 서비스에서 그들을 받고 있기 때문에 당신은 번호를 알고하지 않습니다.

올바른 방법은 ListView를 사용하는 것입니다. ListView을 사용하면 원하는 유형의 요소를 추가 할 수 있습니다. android.Routlay.simple_list_item_1을 행 레이아웃으로 사용한 다음 각 텍스트를 각 새 행에 추가하십시오.

자세한 내용은 this을 확인하십시오.

+0

서비스에서 반환 된 각 객체에 대해 6 행과 7 열이있는 tableView를 사용해야합니다. 감사합니다 조언 =) – guneraykut

관련 문제