相关疑难解决方法(0)

如何为AutoCompleteTextView创建自定义BaseAdapter

我一直在为AutoCompleteTextView创建自定义ArrayAdapter时遇到困难,尽管在互联网上找到以下代码,但仍会出现这样的错误:

  • 下拉列表不会出现.
  • 自定义对象及其详细信息不会出现.

因此,对于那些遇到或遇到与我相同问题的人,我建议使用BaseAdapter代替AutoCompleteTextView.

android autocompletetextview android-arrayadapter baseadapter

10
推荐指数
2
解决办法
2万
查看次数

java.io.IOException出现此错误的原因是什么:Content-Length和流长度不一致

我收到了这个错误

   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)

android okhttp

10
推荐指数
1
解决办法
1万
查看次数