我在google inapp上工作, 下面是我的代碼我想要獲取我所有inapp產品的所有信息,但如何比較arraylist對象與字符串,它顯示for循環錯誤「can not元素類型的對象轉換爲字符串」google inapp在android中的詳細信息
ArrayList skuList = new ArrayList();
skuList.add("premiumUpgrade");
skuList.add("gas");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails = mService.getSkuDetails(3, getPackageName(),"inapp", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0)
{
ArrayList responseList
= skuDetails.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList)
{
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
if (sku.equals("premiumUpgrade"))
{
// mPremiumUpgradePrice = price;
Log.i("price", price);
} else if (sku.equals("gas")) {
// mGasPrice = price;
Log.i("price", price);
}
}
}
你可以給我們的錯誤和相關的崩潰日誌? – Poutrathor
它在for循環中,它不允許在for循環中使用responselist,因爲它是一個數組列表,它顯示「不能將元素類型對象轉換爲字符串」 – pitu