0

我有代码来显示这样的商店。我还在学习android,

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // getting values from selected ListItem
                String pid = ((TextView) view.findViewById(R.id.id_store)).getText()
                        .toString();

                // Starting new intent
               Intent in = new Intent(getApplicationContext(),
                      editstoreActivity.class);
                // sending pid to next activity
                in.putExtra("phone", mPhoneNumber);
                in.putExtra(TAG_PID, pid);

                // starting new activity and expecting some response back
                startActivityForResult(in, 100);
            }
        });

但它显示这样的错误

10-05 12:17:56.149: INFO/ActivityManager(59): Starting activity: Intent { cmp=shoop3.android.edu/.editstoreActivity (has extras) }
10-05 12:17:58.289: DEBUG/dalvikvm(957): GC_FOR_MALLOC freed 1530 objects / 274448 bytes in 208ms
10-05 12:17:59.649: ERROR/JSON Parser(957): Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
10-05 12:17:59.669: DEBUG/Single Store Details(957): {"store":[{"id_user":"63","id_platform":"1","store_url":"url.com","store_desc":"wordpress","id_store":"42","store_logo":null,"store_name":"toko wordpress edit","store_curr":null},{"id_user":"63","id_platform":"2","store_url":"pres.com","store_desc":"prestashop","id_store":"43","store_logo":null,"store_name":"toko prestashop","store_curr":null}]}
10-05 12:18:00.899: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.editstoreActivity: 4664 ms (total 4664 ms)
10-05 12:18:58.339: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
10-05 12:23:58.343: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol

我真的很困惑,有什么解决办法吗??请

4

2 回答 2

0

我假设您正在尝试解析 json 中的响应,其中响应位于 xml 中。更好的是,你使用一些 XML 解析器,比如

  1. SAX 解析器
  2. DOM 解析器
  3. XMLPULL 解析器
于 2012-10-05T05:31:25.513 回答
0

您可能正在尝试将 JSON 转换为 String 。尝试使用 Gson 。它具有将 JSON 转换为字符串的方法

于 2012-10-05T05:36:13.803 回答