how to resolve java.lang.string cannot be cast to java.lang.integer android with xml parser

前端 未结 2 2025
温柔的废话
温柔的废话 2021-01-14 18:52

I am trying to parse XML and display it into list view, but after running the app nothing happens -- the list is displayed but not with the XML data . I don\'t know if I am

2条回答
  •  萌比男神i
    2021-01-14 19:28

    You cannot directly change or reference your String object to Integer type because there is no parent-child relationship between these two classes.

    If you try to cast a String to a Integer in such a way, it will raise a ClassCastException.

    String someValue = "123";
    Integer intValue = (Integer) someValue; // ClassCastException Raise.
    

    So if you want to change or reference a String Variable to Integer, you must use parsing techniques.

    int intValue = Integer.parseInt(someValue); //this code will work for this.
    

提交回复
热议问题