使用2个条件筛选AutoCompleteTextView结果

时间:2013-02-05 08:35:17

标签: android autocompletetextview

我有一个RTL应用程序,它在AutoCompleteTextView小部件中显示客户名称。现在我的toString()是这样的,所以它根据名称过滤结果。现在我想更进一步,允许我的用户根据名称和代码搜索客户。我该怎么做。我使用的是Android 2.3.3版。

public String toString() {
    return getName;
}

======

    private void loadCustomers() {
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                customers = getConnection().getCustomers();
                BaseKaizenActivity.getStorageManager().setCustomers(
                        customers);
                Log.d("---", "loaded customers: " + customers.size());

                handleSuccess(customers);
            } catch (Exception exc) {
                Log.d("--- ERROR ---", exc.getMessage());
                handleException(exc.getMessage());
            }
        }
    });
    thread.start();
}  

======

private void handleSuccess(final List<Customer> customers) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {

            final ArrayAdapter<Customer> customerSpinner = new ArrayAdapter<Customer>(
                    MainMenuActivity.this,
                    android.R.layout.simple_spinner_item, customers);
            customerSpinner
                    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            customerTextView.setAdapter(customerSpinner);


            if (progressDialog != null) {
                progressDialog.dismiss();
                progressDialog = null;
            }
        }
    });
}  

==========

@Override
public List<Customer> getCustomers() {
    List<NameValuePair> params = new ArrayList<NameValuePair>(1);
    params.add(new BasicNameValuePair("action", "customer"));
    try {
        String response = executeHttpPost(params);
        String[] result = split(response);

        List<Customer> customers = new ArrayList<Customer>();

        for (int i = 2; i < result.length; i += 18) {
            String id = result[i + 0];
            String code = result[i + 1];

            String name = result[i + 3];

            String address = result[i + 4];
            String type = result[i + 5];

            String phoneNo = result[i + 6];
            String mobileNo = result[i + 7];
            String faxNo = result[i + 8];       

            Customer customer = new Customer(id, code, name, address, type,phoneNo,mobileNo,faxNo);
                    customers.add(customer);

        }
        Log.d("----", "" + customers.size());           
        return customers;
    }
    catch (Exception exc) {
        Log.e("----", exc.getMessage(), exc);
        throw new ConnectionException(exc.getMessage());
    }
}

0 个答案:

没有答案