TableRow added via program is not bringing all fields!

2

I'm trying to make a ScrollView - TableLayout - TableRow via program, but using an XML Layout as the basis of the internal data of TableRows.

It happens that whenever I try to add the text of the last field (message) of this layout or only inflate the layout, it does away with some definitions that are directly in the xml and the dt_envio field stops appearing.

I must be doing something wrong, but I can not find the error! Could someone help me?

fragment_comunicado.xml     

<LinearLayout
    android:layout_width="170dp"
    android:layout_height="120dp"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/logoEscola"
        android:layout_width="170dp"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:src="@drawable/logo_escola" />
</LinearLayout>

<FrameLayout
    android:id="@+id/content_frame_comunicado"
    android:layout_width="match_parent"
    android:layout_height="290dp"
    android:layout_marginEnd="20dp"
    android:layout_marginStart="20dp">
</FrameLayout>

fragment_comunicado_tablerow.xml     

<ImageView
    android:id="@+id/img_remetente"
    android:layout_width="65dp"
    android:layout_height="71dp"
    android:gravity="center"
    android:src="@drawable/ic_chat" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_seta_close" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/remetente"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:singleLine="true"
                android:text="Remetente Remetente Remetente Remetente Remetente"
                android:textColor="@color/azul_painel"
                android:textSize="7pt"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/dt_envio"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="99-99-9999"
                android:textSize="5pt"
                android:textStyle="italic" />
        </LinearLayout>
    </LinearLayout>

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

        <TextView
            android:id="@+id/assunto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:text="Assunto Email"
            android:textColor="@color/azul_painel"
            android:textSize="6pt"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/mensagem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:text="Inicio Email"
            android:textColor="@color/azul1_painel"
            android:textSize="6pt"
            android:textStyle="bold|italic" />

    </LinearLayout>

</LinearLayout>

FragmentComunicado.java

public class FragmentComunicado extends Fragment{

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    final View rootView = inflater.inflate(R.layout.fragment_comunicado, container, false);
    ((MenuPrincipal)getActivity()).setActionBarTitle("Comunicado");

    //** Fazer Chamada pesquisa dos comunicados por: aluno e ano

    FrameLayout fl = (FrameLayout) rootView.findViewById(R.id.content_frame_comunicado);
    fl.removeAllViews();

    ScrollView sv = new ScrollView(rootView.getContext());
    FrameLayout.LayoutParams lpsv = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    sv.setLayoutParams(lpsv);

    TableLayout tl = new TableLayout(rootView.getContext());
    TableLayout.LayoutParams lptl = new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    tl.setLayoutParams(lptl);
    sv.addView(tl);

    for (int i = 1; i <10; i++){
        TableRow tr = new TableRow(rootView.getContext());
        tl.addView(tr);

        View tablerow = inflater.inflate(R.layout.fragment_comunicado_tablerow, tr, false);

        ImageView img_remetente = (ImageView) tablerow.findViewById(R.id.img_remetente);
        img_remetente.setImageResource(R.drawable.logo_escola);

        TextView remetente = (TextView) tablerow.findViewById(R.id.remetente);
        remetente.setText("Coord. Educacao Infantil");

        TextView dt_envio = (TextView) tablerow.findViewById(R.id.dt_envio);
        dt_envio.setText("02/01/2016");

        TextView assunto = (TextView) tablerow.findViewById(R.id.assunto);
        assunto.setText("Inicio Curso de Ferias");

        TextView mensagem = (TextView) tablerow.findViewById(R.id.mensagem);
        mensagem.setText("Bom dia Srs Pais, Nosso curso de ferias inicia-se cheio de atividades para nossos pequenos!!! Nesta semana teremos aventura no zoologico");

        tr.addView(tablerow);


    }

    fl.addView(sv);

    return rootView;

}
}
    
asked by anonymous 05.01.2016 / 18:56

1 answer

0

Hey everyone,

It was a matter of "getting the ears out of the eyes" anyway.

When I set up my TableRow via the program, I forgot to mount the layout_height and layout_width. As soon as I rode, it worked perfectly. : D

    
06.01.2016 / 22:18