मुझे कोड के साथ जनरेट किए गए TableRow, Textview और इसी तरह के मामले में कुछ समस्या है। भले ही ओनिमुश का जवाब अच्छा लगता हो, यह उत्पन्न यूआई के साथ काम नहीं करता है।
यहाँ एक कोड है जो काम नहीं करता है ....
TableRow the_ligne_unidade = new TableRow(this);
the_ligne_unidade.setBackgroundColor(the_grey);
TextView my_unidade = new TextView(this);
my_unidade.setText(tsap_unidade_nom);
my_unidade.setTextSize(20);
my_unidade.setTypeface(null, Typeface.BOLD);
my_unidade.setVisibility(View.VISIBLE);
TableRow.LayoutParams the_param;
the_param = (TableRow.LayoutParams)my_unidade.getLayoutParams();
the_param.span = 3;
my_unidade.setLayoutParams(the_param);
// Put the TextView in the TableRow
the_ligne_unidade.addView(my_unidade);
कोड ठीक प्रतीत होता है लेकिन, जब आप "the_params" की पहुंच तक पहुँचते हैं तो यह NULL देता है।
दूसरे छोर पर, यह कोड एक आकर्षण की तरह काम करता है:
TableRow the_ligne_unidade = new TableRow(this);
the_ligne_unidade.setBackgroundColor(the_grey);
TextView my_unidade = new TextView(this);
my_unidade.setText(tsap_unidade_nom);
my_unidade.setTextSize(20);
my_unidade.setTypeface(null, Typeface.BOLD);
my_unidade.setVisibility(View.VISIBLE);
// Put the TextView in the TableRow
the_ligne_unidade.addView(my_unidade);
// And now, we change the SPAN
TableRow.LayoutParams the_param;
the_param = (TableRow.LayoutParams)my_unidade.getLayoutParams();
the_param.span = 3;
my_unidade.setLayoutParams(the_param);
फर्क सिर्फ इतना है कि मैं स्पैन सेट करने से पहले टैक्स्टव्यू को TableRow के अंदर धकेल देता हूं। और इस मामले में, यह काम करता है। आशा है कि यह किसी की मदद करेगा!