我有一个问题要解决,我有三个文本视图数组。
- Textview a[];
- TexTview b[];
- TexTview c[]:
我需要在表格中显示它们,如下所示:因为我需要显示它。但是当用以下代码显示时,屏幕是这样的:所以不需要像这样sho
((ViewGroup) layout).addView(a[i]);
((ViewGroup)layout).addView(a[i]);
((ViewGroup)layout).addView(a[i]);
这是完整的代码,提前,非常感谢。
public class MainActivity extends Activity {
SitesList sitesList = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/** Create a new layout to display the view */
View layout = findViewById(R.id.layout);
/** Create a new textview array to display the results */
TextView variacion[];
TextView nemotecnico[];
TextView precio[];
try {
/** Handling XML */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
/** Send URL to parse XML Tags */
URL sourceUrl = new URL("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=75");
/** Create handler to handle XML Tags ( extends DefaultHandler ) */
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
/** Get result from MyXMLHandler SitlesList Object */
sitesList = MyXMLHandler.sitesList;
/** Assign textview array lenght by arraylist size */
// registro = new TextView[sitesList.getRegistro().size()];
nemotecnico = new TextView[sitesList.getNemotecnico().size()];
variacion = new TextView[sitesList.getVariacion().size()];
precio = new TextView[sitesList.getPrecio().size()];
/** Set the result text in textview and add it to layout */
for (int i = 0; i < sitesList.getRegistro().size(); i++) {
variacion[i] = new TextView(this);
variacion[i].setText(sitesList.getVariacion().get(i));
nemotecnico[i] = new TextView(this);
nemotecnico[i].setText(sitesList.getNemotecnico().get(i));
precio[i] = new TextView(this);
precio[i].setText(sitesList.getPrecio().get(i));
((ViewGroup)layout).addView(nemotecnico[i]);
((ViewGroup)layout).addView(variacion[i]);
((ViewGroup)layout).addView(precio[i]);
}
/** Set the layout view to display */
setContentView(layout);
}
}