TextWatcher for Autocomplete视图

时间:2015-05-06 12:21:06

标签: android json autocompletetextview textwatcher

当在自动填充文本视图中添加或删除了一封信时,我试图连续调用json webservice。这里的一切都在这里运作良好。但是当我尝试从自动完成文本视图生成的列表中选择一个选项时,现在再次调用Json并且应用程序崩溃。 (即)在自动完成中选择的值再次作为参数传递给json get方法,应用程序崩溃。任何人都可以帮我解决这个问题。

disabled={this.state.disabled}

这是我的筹码:

companyName_autoComplete = (AutoCompleteTextView) findViewById(R.id.companyName_autoComplete);

selectIndustry_button.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            SearchCPS_WS();
        }
    });


private void SearchCPS_WS() {

AsyncHttpClient client = new AsyncHttpClient();
        RequestParams params = new RequestParams();

        Log.i("WebService", "WebService: "+Httppost_Links.SEARCH_COMPANY_NAME_ADD_COMPANY+textInAutoComplete+"5@0");

        client.get(Httppost_Links.SEARCH_COMPANY_NAME_ADD_COMPANY+textInAutoComplete+"/5@0", params,
                new AsyncHttpResponseHandler() {

                    @Override
                    public void onSuccess(String response) {
                        // TODO Auto-generated method stub

                        Log.i("SearchCPS_WS response: ",
                                "SearchCPS_WS response: " + response);


}

1 个答案:

答案 0 :(得分:2)

这是因为您的网址中包含空格,此部分:

Fountain Powerboat Industries, Inc.

您可以根据URI specification替换那些%20