JavaRush /จาวาบล็อก /Random-TH /ต้องการความช่วยเหลือเกี่ยวกับ android
Samson
ระดับ

ต้องการความช่วยเหลือเกี่ยวกับ android

เผยแพร่ในกลุ่ม
สาระสำคัญของปัญหาคือมีโครงร่างที่ SAX parser ทำงานและดึงอัตราแลกเปลี่ยนเหล่านี้จากอินเทอร์เน็ต เมื่อฉันเพิ่มลงใน ListView โปรแกรมไม่เริ่มทำงาน แต่เมื่อส่งออกไปยังคอนโซลมีข้อมูล โปรดช่วยฉันค้นหาว่าข้อผิดพลาดอยู่ที่ไหน (ตัวอย่าง XML สำหรับ ListView สร้าง my_list_items_currensy นี้) public class ShowAllActivity extends AppCompatActivity { private ArrayList finalList; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_layout); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); try { URL url = new URL("http://resources.finance.ua/ua/public/currency-cash.xml"); InputStream stream = url.openStream(); SAXParser saxParser = saxParserFactory.newSAXParser(); // creating a SAX parser Handler handler = new Handler(); saxParser.parse(stream,handler); // here we parse our resource finalList = handler.getListOfAllCurrencies(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } adapterList(); } public void adapterList(){ ArrayAdapter arrayAdapter = new ListOfAllCurrency(); ListView listView=(ListView)findViewById(R.id.c_list); listView.setAdapter(arrayAdapter); } public class ListOfAllCurrency extends ArrayAdapter { public ListOfAllCurrency() { super(ShowAllActivity.this,R.layout.my_list_items_currensy,finalList); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if( view==null){ view = getLayoutInflater().inflate(R.layout.my_list_items_currensy,parent,false); } TextView bankName = (TextView)view.findViewById(R.id.bankName); TextView currency = (TextView)view.findViewById(R.id.currency); TextView bay = (TextView)view.findViewById(R.id.bay); TextView sell = (TextView)view.findViewById(R.id.sell); bankName.setText(finalList.get(position).getBankName()); StringBuilder itemsString = new StringBuilder(); int lengthListOfCurrency = finalList.get(position).getList().size(); for(int i=0;i
ความคิดเห็น
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION