我一直在为AutoCompleteTextView创建自定义ArrayAdapter时遇到困难,尽管在互联网上找到以下代码,但仍会出现这样的错误:
因此,对于那些遇到或遇到与我相同问题的人,我建议使用BaseAdapter代替AutoCompleteTextView.
android autocompletetextview android-arrayadapter baseadapter
我收到了这个错误
java.io.IOException: Content-Length and stream length disagree
Run Code Online (Sandbox Code Playgroud)
在这行代码上 return response.body().bytes();
这是完整的代码
编辑:在一些谷歌之后,错误的原因来自okhttp lib
if (contentLength != -1L && contentLength != bytes.size.toLong()) {
throw IOException(
"Content-Length ($contentLength) and stream length (${bytes.size}) disagree")
}
Run Code Online (Sandbox Code Playgroud)
但是如何解决这个问题?
编辑:
这是完整的代码:
public class OkHttpHandler extends AsyncTask<Void, Void, byte[]> {
private final String Fetch_URL = "http://justedhak.comlu.com/get-data.php";
ArrayList<Listitem> Listitem;
int resulta;
OkHttpClient httpClient = new OkHttpClient();
String myJSON;
JSONArray peoples = null;
InputStream inputStream = null;
@Override
protected byte[] doInBackground(Void... params) {
Log.d("e", "dddddddddd");
Log.d("e", Fetch_URL);
Request.Builder …Run Code Online (Sandbox Code Playgroud)