Xml的颜色取决于变量

时间:2012-08-16 14:27:29

标签: android xml colors xml-parsing

我有一个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);

    }

}

My Handler

My Parser

我有属性“compra”,如果(compra&gt; 0),我需要颜色为绿色。否则,颜色应为红色。

0 个答案:

没有答案