android - 自动完成文本视图未更新

时间:2013-03-13 11:57:22

标签: android autocomplete progress-bar

我尝试从文本框中键入的基于Web服务的文本更新自动完成textview数据。它工作正常但我在Web服务调用时放入了进度条,因为在这种情况下需要一些时间自动完成文本视图没有显示下拉菜单。我猜自动完成textview在进度条被解雇时被解雇。在这种情况下我们应该如何设置进度条。

Code

类GetFundNames扩展了AsyncTask {

    ProgressDialog progress = new ProgressDialog(BasicAutoText.this);

    @Override
    protected void onPreExecute() {
        Log.d("TAG", "onPreExecute()");
        progress.setMessage("Please wait...");
        progress.setCanceledOnTouchOutside(false);
        progress.show();
    }

    @Override
    // three dots is java for an array of strings
    protected String doInBackground(Void... args) {

        try {
            response = getNames(strKeyword);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        ;

        return response;
    }

    // then our post

    @Override
    protected void onPostExecute(String response) {

        if(progress.isShowing())
        {
            progress.dismiss();
        }

        if (ETF_Constants.registerResponsevalue == 200) {
            JSONArray arObjects;
            try {
                arObjects = new JSONArray(response);
                arProducts = new ArrayList<ProductData>();
                arProducts.clear();
                for (int i = 0; i < arObjects.length(); i++) {
                    JSONObject jOb = arObjects.getJSONObject(i);
                    ProductData pd = new ProductData();

                    int fundId = jOb.getInt("fundId");
                    String con = "" + fundId;
                    String fundName = jOb.getString("fundName");
                    String priceAndDate = jOb.getString("priceAndDate");
                    String recentGain = jOb.getString("recentGain");
                    String recentGrowth = jOb.getString("recentGrowth");
                    String tickerName = jOb.getString("tickerName");

                    pd.fundId = con;
                    pd.fundName = fundName;
                    pd.priceAndDate = priceAndDate;
                    pd.recentGain = recentGain;
                    pd.recentGrowth = recentGrowth;
                    pd.tickerName = tickerName;

                    arProducts.add(pd);
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // autocomplete
            adapter = new ArrayAdapter<String>(BasicAutoText.this,
                    R.layout.advancelist);
            adapter.setNotifyOnChange(true);
            AUTO_View.setAdapter(adapter);

            System.out.println("adapter" + adapter);
            for (int i = 0; i < arProducts.size(); i++) {
                adapter.add(arProducts.get(i).fundName);
                System.out.println("Fund Name:"
                        + arProducts.get(i).fundName);
            }
            System.out.println("arProducts count:" + arProducts.size());
            System.out.println("adapter count:" + adapter.getCount());

            adapter.notifyDataSetChanged();

        } 
    }

}

0 个答案:

没有答案