2013-05-29 3 views
0

Это не дает мне ничего .. где я что-то пропустил любой один помочь мне разобраться не показывая изображение как хорошо, что я TextView добавить к относительному макетеRealtivelayout добавить в строку таблицы

 RelativeLayout.LayoutParams tParams = new RelativeLayout.LayoutParams 
       (LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); 
     tParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); 
     tParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); 

     LayoutParams rlParams = new LayoutParams(LayoutParams.FILL_PARENT 
       ,LayoutParams.FILL_PARENT); 



        for (int i=0; i < Math.ceil(MyContants.servicemodellist.size()/2); i++) { 
         TextView txt= new TextView(RoomservicsFirstPage.this); 
         txt.setText(MyContants.servicemodellist.get(i).getOption_text_1()); 

         RelativeLayout rLayout = new RelativeLayout(RoomservicsFirstPage.this); 
         txt.setLayoutParams(tParams); 
         rLayout.setLayoutParams(rlParams); 
          // Adding the TextView to the RelativeLayout as a child 
         ImageView image = new ImageView(RoomservicsFirstPage.this); 

         image.setLayoutParams(rlParams); 
         download(MyContants.servicemodellist.get(i).getImage(),image); 
         rLayout.addView(image); 
         rLayout.addView(txt); 
         rows.addView(rLayout); 

}

Я решить мою проблему .. Я не добавить параметры макета, когда добавить макет в буксировке :)

ответ

1
package com.example.test; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.ViewGroup.LayoutParams; 
import android.widget.ImageView; 
import android.widget.RelativeLayout; 
import android.widget.TableRow; 
import android.widget.TextView; 

public class MainActivity extends Activity { 
    TableRow rows; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     rows = (TableRow) findViewById(R.id.rows); 
     RelativeLayout.LayoutParams tParams = new RelativeLayout.LayoutParams(
      LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
     tParams.addRule(RelativeLayout.ALIGN_LEFT); 

     for (int i = 0; i < 10; i++) { 
      TextView txt = new TextView(this); 
      txt.setText("" + i); 
      txt.setId(i + 1); 
      RelativeLayout rLayout = new RelativeLayout(this); 
      txt.setLayoutParams(tParams); 
      // Adding the TextView to the RelativeLayout as a child 
      ImageView image = new ImageView(this); 
      image.setImageResource(R.drawable.ic_launcher); 
      RelativeLayout.LayoutParams iParams = new RelativeLayout.LayoutParams(
        20, 20); 
      iParams.addRule(RelativeLayout.RIGHT_OF, i + 1); 

      image.setLayoutParams(iParams); 
      rLayout.addView(image); 
      rLayout.addView(txt); 
      rows.addView(rLayout); 
     } 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.activity_main, menu); 
     return true; 
    } 
} 
+0

Я решить эту проблему раньше, но Thanx ... :) – murtazamehmood

Смежные вопросы