I am creating an android app consists of a custom alert dialog.In that dialog i want to create a table layout dynamically with 4 rows and 5 columns. I want to made this with in thread can any one tell me how to create table layout dynamically inside thread This is what i had done but it was showing only dialog name but not the table layout inside thread EDITED:
progresDialog = new Dialog(getActivity());
progresDialog.setContentView(R.layout.progressdialog);
progresDialog.setTitle("MANUAL MODE : TESTING ");
testing_after_fuse_cnc = new Thread(new Runnable() {
@Override
public void run() {
update_handler.post(new Runnable() {
@Override
public void run() {
table_dialog = new TableLayout(getActivity());
table_dialog.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
table_dialog.setBackgroundColor(Color.parseColor("#FFFFFF"));
for(i=1;i<3;i++){
tablerow_dialog = new TableRow(getActivity());
tablerow_dialog.setLayoutParams(new LayoutParams(android.widget.TableRow.LayoutParams.WRAP_CONTENT,android.widget.TableRow.LayoutParams.WRAP_CONTENT));
for(j=1;j<4;j++){
TextView t_v_dialog = new TextView(getActivity());
t_v_dialog.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
t_v_dialog.setBackgroundResource(R.drawable.cell_shape);
t_v_dialog.setPadding(5,5,5, 5);
tablerow_dialog.addView(t_v_dialog);
}
table_dialog.addView(tablerow_dialog);
}
}
});
}
});
testing_after_fuse_cnc.start();
progresDialog.show();
答案 0 :(得分:1)
行
table_row.addView(t_v_dialog);
}
table_dialog.addView(table_row);
应该是
tablerow_dialog.addView(t_v_dialog);
}
table_dialog.addView(tablerow_dialog);
不要忘记将table_dialog
添加到您的布局容器中。