基于应用的数据解析自我暗示查询结果 [英] Parse auto-suggestion query results based on app data

查看:99
本文介绍了基于应用的数据解析自我暗示查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下,如果有是检索,以帮助我找到需要一个用户的信息基于用户输入的部分结果的任何可用选项。其实,我想实现一个添加好友功能,而用户是打字我想,部分成果在组合框中(如Facebook)上显示。

I would like to ask if there is any available option to retrieve partial results based on user input in order to help me to find the information need that user has. Actually, i would like to implement an add friend function and i would like while user is typing, the partial results to be shown in a combo box (like facebook).

例如我想,当用户键入广告,在TextView中看到一个下拉列表(或别的东西),还有一些类似的结果{adamos,安德鲁,安迪}。

For example i would like when user types "ad" in the textview to see a dropdown list(or something else) with some results like {adamos,andrew,andy}.

现在用的解析在后台,我想从那里供养下拉列表中(实时)。

Am using Parse at the backend and i want to feed the dropdown list from there(realtime).

谢谢,
Adamos

Thanks, Adamos

推荐答案

这仅仅是个大概的了解。根据您的方便更改code。

This is just the rough idea. Change the code according to your convenience.

adapter = new ArrayAdapter<String>(this, R.layout.autocompleteadapter);
    adapter.setNotifyOnChange(true);
    search.setAdapter(adapter);
    search.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            if (count % 3 == 1) {
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        search.setDropDownHeight(LayoutParams.WRAP_CONTENT);
                        adapter.clear();
                        // Run you background task here
                        new AutoCompleteEditTextTask()
                                .execute(search.getText().toString());
                    }
                }, 1000);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {

        }

        public void afterTextChanged(Editable s) {

        }
    });
    search.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterview, View v,
                int position, long arg3) {
            // TODO Auto-generated method stub
            search.setText(adapterview.getItemAtPosition(position)
                    .toString());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });

这篇关于基于应用的数据解析自我暗示查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆