-1

I have two AutoCompleteTextView in which one is mapped with another like if I select value in first AutoCompleteTextView1 then according to the value it shows the second AutoCompleteTextView2 values which is mapped in database. It works fine but when I come thro on Resume its not working. I need to delete both values and select 1st actv and next actv every time.

    // manufacturer
            manufactureArray = mDbHelper.getManufacturer(productid);
            final ArrayAdapter<String> manDesc_adapter = new ArrayAdapter<String>(this,
                    android.R.layout.select_dialog_item, manufactureArray);
            Manufacturer.setThreshold(1);
            Manufacturer.setAdapter(manDesc_adapter);

            Manufacturer.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                        long arg3) {
                    // TODO Auto-generated method stub
            as_Manufacturer = Manufacturer.getText().toString();    
            branchname = mDbHelper.fetchvalue("lead_table", leadid, "lead_id",
                            "branchID");

            dealerArray = mDbHelper.getDealer(productid, branchname, as_Manufacturer);
            ArrayAdapter<String> makeAdapter = new ArrayAdapter<String>(                        Asset.this, android.R.layout.select_dialog_item,makeArray);     
ArrayAdapter<String> supplierAdapter = new ArrayAdapter<String>(Asset.this,
                        android.R.layout.select_dialog_item, dealerArray);
                    supplier.setThreshold(1);
                    supplier.setAdapter(supplierAdapter);                   
                    }

            });

            // supplier or dealer
        supplier.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
        // TODO Auto-generated method stub
        as_Supplier_Dealer_Name = supplier.getText().toString();

                        }

                    });

supplier.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
                        as_Supplier_Dealer_Name = supplier.getText().toString();
                        for (int i = 0; i < dealerArray.size(); i++) {
                            if (as_Supplier_Dealer_Name.equals(dealerArray.get(i))) {
                                sCount = 1;
                                break;
                            } else {
                                sCount = 0;
                            }
                        }
                    }
                });

Here manufacturer is an autocompleteteextview for which the supplier is filtered whose values are fetched from database. Please help me as am stuck for a day on this.

Pooja
  • 241
  • 2
  • 3
  • 11
  • Store the data, and could you elaborate a bit more about your problem? – Yauraw Gadav Dec 27 '13 at 23:32
  • @GaurawYadav Hi i have two autoCompleteText Manufacturer and Supplier. After selecting Manufacturer the Supplier gets filtered and shows only the values which is mapped to the respective Manufacturer. But my query is when I come from On Resume to the same Instance and change anything in Supplier its not working unless I edit the Manufacturer, is there any good solution for the same – Pooja Dec 28 '13 at 08:02

1 Answers1

1

Notify data changed on the adapter to populate again the adapter.

Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39