私はこの作業を行っていましたが、どこかで変更を加えましたが、今はエラーを追跡できません。android parse xml - Nodelistのオブジェクトが多すぎます
ここでは... _regionListを作成すると、使用している領域のxmlファイルに13の領域がありますが、_regionlist/children /配列には18個のオブジェクトがあります。別の領域(50要素)を使用して、60個のオブジェクトを作成します。
アレイ内の残りのオブジェクトには、もちろんヌルIDが付いていますが、これは問題です。どのように追加のオブジェクトがそこにスローされているかに関する考え?
おかげ
// XMLファイルを解析し
public void Parse(InputStream inStream, String inRegion)
{
try {
String _region = inRegion;
this.cFactory = DocumentBuilderFactory.newInstance();
this.cBuilder = this.cFactory.newDocumentBuilder();
this.cBuilder.isValidating();
Document _document = this.cBuilder.parse(inStream, null);
_document.getDocumentElement().normalize();
NodeList _regionList = _document.getElementsByTagName(_region);
final int _length = _regionList.getLength();
for (int i = 0; i < _length; i++) {
final NamedNodeMap _attr = _regionList.item(i).getAttributes();
final String _regionName = GetNodeValue(_attr, "name");
// Construct a Region object
PropertiesRegion _regionObject = new PropertiesRegion(_regionName);
// Add to list
this.cList.add(_regionObject);
Log.d(TAG, _regionObject.toString());
}
}
catch (SAXException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
}
_document、_regionListおよびcListはすべて、追加の配列要素で初期化されます。 TrimToSizeは適切なソリューションのようですが、それは有効なオプションではありません。余計な配列インデックスを削除する必要がある他のオプションを確認できません。アイデア? – user1222760