0
這是我收到的錯誤。如何從陣列中填充微調器
空指針異常 11-06 19:03:34.050:警告/ System.err的(5342):在RetrievingAmazonXMLDataActivity.onCreate(RetrievingAmazonXMLDataActivity.java:88)
for (int i = 0; i < tokens.length; i++) {
String a = dumpTitles("ProductName", i);
element = a.split("!");
allProducts.add(element);
}
w = (String[][])allProducts.toArray(new String[allProducts.size()][]);
Spinner spinnerProducts = (Spinner) findViewById(R.id.spinner2);
spinnerProducts.setOnItemSelectedListener(this);
// **** error line below
ArrayAdapter<String> productsArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, productArrayToShow);
productsArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerProducts.setAdapter(productsArrayAdapter);
public void onItemSelected(AdapterView<?> parent, View v, int position, long id)
{
try {
selected = parent.getItemAtPosition(position).toString();
productArrayToShow = w[position];
} catch (Exception e) {}
}