我有一个XML解析器:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = new TextView(this);
try{
URL url = new URL("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=7002");
ExampleHandler7002 myExampleHandler = new ExampleHandler7002();
Xml.parse(url.openStream(), Xml.Encoding.UTF_8, myExampleHandler);
List<ParsedExample7002> parsedExampleDataSetList =
myExampleHandler.getParsedData();
for(ParsedExample7002 parsedExampleDataSet : parsedExampleDataSetList){
tv.append(parsedExampleDataSet.toString());
}
} catch (Exception e) {
/* Display any Error to the GUI. */
tv.setText("Error: " + e.getMessage());
}
/* Display the TextView. */
this.setContentView(tv);
}
}
我有属性“compra”,如果(compra&gt; 0),我需要颜色为绿色。否则,颜色应为红色。