2012-04-10 105 views
0

看看代碼片斷波紋管是爲Android爲什麼添加的視圖沒有出現在屏幕上?

 
TableLayout tbL = (TableLayout) findViewById(R.id.moreInfo_table);

tbL.addView(getRow(key, value), new TableLayout.LayoutParams (TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT)); private TableRow getRow(String key, String value) { TableRow tbR = new TableRow(this); try { TextView keyTV = new TextView(this); keyTV.setText("Key "); keyTV.setTextColor(Color.WHITE); keyTV.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); keyTV.setTextSize(18.0F); TextView valueTV = new TextView(this); valueTV.setText("Value "); valueTV.setTextColor(Color.WHITE); valueTV.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); valueTV.setTextSize(18.0F); tbR.addView(keyTV,new TableLayout.LayoutParams (TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT)); tbR.addView(valueTV,new TableLayout.LayoutParams (TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT)); } catch (Exception e) { e.printStackTrace(); } return tbR; }

問題出在哪裏??????!

+0

你有沒有的setContentView()的活動? xml文件中moreInfo_table的佈局參數是什麼?最好的祝福。 – pouzzler 2012-04-10 16:30:50

+0

'' 但它的主要內容是針對BART – 2012-04-10 16:41:56

回答

0

一旦嘗試更改textcolor ;;

keyTV.setTextColor(Color.WHITE); 

keyTV.setTextColor(Color.BLUE); 

可能是你的觀點出現,但由於白色是不可見的。

+0

沒有,背景色爲黑色 – 2012-04-10 16:43:11

+0

可以粘貼您的完整XMLFILE – 2012-04-10 16:51:19

+0

這是很長的 – 2012-04-10 17:12:41

0

下面是完整的XML文件

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/recipeName_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:gravity="center" 
     android:text="Recipe Name..." 
     android:textSize="24sp" /> 
    <TabHost 
     android:id="@+id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/vidThums" 
     android:layout_below="@+id/recipeName_view" > 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 
      </TabWidget> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <ScrollView 
        android:id="@+id/descr" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/vidThums" 
        android:layout_below="@+id/ingVu" > 

        <LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" > 

         <TextView 
          android:id="@+id/descriptionView" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:text="The name came from ..., and so forth" 
          android:textSize="24sp" /> 
        </LinearLayout> 
       </ScrollView> 

       <LinearLayout 
        android:id="@+id/ingDet" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/vidThums" 
        android:layout_below="@+id/ingVu" 
        android:orientation="vertical" > 

        <ListView 
         android:id="@+id/ingridientsList" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="10dp" 
         android:layout_marginRight="5dp" 
         android:layout_weight=".50" 
         android:cacheColorHint="#00000000" 
         android:clickable="true" 
         android:divider="@drawable/list_divider1" 
         android:dividerHeight="20dp" 
         android:drawSelectorOnTop="false" 
         android:listSelector="@drawable/list_sel1" 
         android:scrollbars="vertical" 
         android:soundEffectsEnabled="true" /> 
       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/prepMethod" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/vidThums" 
        android:layout_below="@+id/ingVu" 
        android:orientation="vertical" > 

        <ListView 
         android:id="@+id/prepMethodList" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="10dp" 
         android:layout_marginRight="5dp" 
         android:cacheColorHint="#00000000" 
         android:clickable="true" 
         android:divider="@drawable/list_divider1" 
         android:dividerHeight="20dp" 
         android:drawSelectorOnTop="false" 
         android:listSelector="@drawable/list_sel1" 
         android:scrollbars="vertical" 
         android:soundEffectsEnabled="true" /> 
       </LinearLayout> 

       <TableLayout 
        android:id="@+id/moreInfo_table" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:background="@drawable/list_selector2" 
        android:scrollbars="vertical" 
        android:stretchColumns="0,1" > 

        <TableRow> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/noOfPersons" /> 

         <TextView 
          android:id="@+id/noPers_view" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/noOfPersons" /> 
        </TableRow> 

        <TableRow> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/rating" /> 

         <RatingBar 
          android:id="@+id/recipRatingBar_details" 
          style="?android:attr/ratingBarStyleSmall" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginBottom="2dp" 
          android:layout_marginTop="5dp" 
          android:numStars="5" 
          android:rating="3" 
          android:stepSize="0.5" /> 
        </TableRow> 

        <TableRow> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/prepTime" /> 

         <TextView 
          android:id="@+id/prepTime_view" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="20" /> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/minutes" /> 
        </TableRow> 

        <TableRow> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/noOfRater" /> 

         <TextView 
          android:id="@+id/noOfRater_view" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="20" /> 
        </TableRow> 
       </TableLayout> 

       <LinearLayout 
        android:id="@+id/rating_tab" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/vidThums" 
        android:layout_below="@+id/ingVu" 
        android:orientation="vertical" > 

        <TextView 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center_horizontal|left" 
         android:text="@string/raterGuid" 
         android:textSize="18sp" /> 

        <RatingBar 
         android:id="@+id/recipRatingBar_rate"       
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="left" 
         android:layout_marginBottom="2dp" 
         android:layout_marginTop="5dp" 
         android:numStars="5" 
         android:rating="0" 
         android:stepSize="0.5" /> 

        <Button 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:gravity="center" 
         android:text="@string/submit" 
         android:textSize="18sp" /> 
       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 

    <HorizontalScrollView 
     android:id="@+id/vidThums" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" > 

     <LinearLayout 
      android:id="@+id/videoThumsHolder" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 
     </LinearLayout> 
    </HorizontalScrollView> 

</RelativeLayout> 
相關問題