tags:

views:

55

answers:

1

Hi, I have some problem and I cannot solve that. In my code I add dynammically ImageButtons( I dynamically create TableRow and add in row), they shows up but I cannot click on them ( I try all, set clickable to true, enabled to true and nothing). If I use Button instead ImageButton all works fine except when I set background for buttons same problem again.

Also I add TextView from code but TextView doesn't show up at all. Any solution pls ?

A: 

//This is function for creating rows from some list **public static TableRow[] Create(List list){ TableRow[] rows=null; try{ rows=new TableRow[list.size()*3]; int i=0;

        for(Apartment ap : list){
            rows[3*i]=new TableRow(activity);
            rows[3*i+1]=new TableRow(activity);
            rows[3*i+2]=new TableRow(activity);

            rows[3*i].setLayoutParams(new LayoutParams( 
                    LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT));
            rows[3*i+1].setLayoutParams(new LayoutParams( 
                    LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT));
            rows[3*i+2].setLayoutParams(new LayoutParams( 
                    LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT));

            EditText txtMainInform=new EditText(activity);

            //txtMainInform.setText(ap.GetMainInformation());
            txtMainInform.setLayoutParams(new LayoutParams( 
                    LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT));
            txtMainInform.setText("vvvvvvvvvvvvvvvvvvvv");
            txtMainInform.setVisibility(1);
            rows[3*i].addView(txtMainInform);
            rows[3*i].setVisibility(1);

            TextView txtMoreInform=new TextView(activity);
            txtMoreInform.setLayoutParams(new LayoutParams( 
                    LayoutParams.WRAP_CONTENT, 
                    LayoutParams.WRAP_CONTENT));
            rows[3*i+1].addView(txtMoreInform);


            ImageButton imbGallery=new ImageButton(activity);
            imbGallery.setClickable(true);
            imbGallery.setEnabled(true);
            imbGallery.setBackgroundResource(R.drawable.gallery_icon);



            ImageButton imbCall=new ImageButton(activity);
            imbCall.setBackgroundResource(R.drawable.phone);

            ImageButton imbMap=new ImageButton(activity);
            imbMap.setBackgroundResource(R.drawable.map);
            rows[3*i+2].addView(imbGallery);
            rows[3*i+2].addView(imbCall);
            rows[3*i+2].addView(imbMap);
            rows[3*i+2].setEnabled(true);
            i++;
        }

    }
    catch(Exception e){

    }
    return rows;
}**

//There I add ImageButtons- this is part of OnCreate function **TableRow[] rows=ResultCreator.Create(list); TableLayout table=(TableLayout)this.findViewById(R.id.result_layout);

        for(TableRow row:rows){
        table.addView(row,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

        }**

//My TableLayout is inside other LinearLayout, make difference ? Thanks

msretractor