Autocomplete textview data Fetch from ksoap webservice, Using Search icon Onclick request with asynchronous task

前端 未结 3 1934
春和景丽
春和景丽 2020-12-12 03:43

How can we fetch Data from ksoap web service, show in Android Autocomplete textview search suggestion, using Onclick Search button.

3条回答
  •  [愿得一人]
    2020-12-12 04:19

    public void getSignupdata(String SearchValue, String CityLocation) 
        {
            // Create request
            SoapObject request = new SoapObject(NAMESPACE2, METHOD_NAME2);
    
            PropertyInfo pi3 = new PropertyInfo();
            pi3.setName("search");
            pi3.setValue(SearchValue);// get the string that is to be sent to the webservice
            pi3.setType(String.class);
            request.addProperty(pi3);
    
            PropertyInfo pi4 = new PropertyInfo();
            pi4.setName("City");
            pi4.setValue(CityLocation);// get the string that is to be sent to the webservice
            pi4.setType(String.class);
            request.addProperty(pi4);
    
            // Create envelope
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            // Set output SOAP object
            envelope.setOutputSoapObject(request);
            // Create HTTP call object
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL2);
    
            try {
                // Invole web service
                androidHttpTransport.call(SOAP_ACTION2, envelope);
                // Get the response
                SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
    
                if ((response.toString()).contains("{")) 
                {
                    // JSONArray jr = new JSONArray(response);
                    SoapObject rep = (SoapObject) envelope.bodyIn;
                    JSONArray jr = new JSONArray(rep.getPropertyAsString(0));
                    for (int i = 0; i < jr.length(); i++) {
                        JSONObject jb = (JSONObject) jr.get(i);
    
    
    
                           ServiceCenterName = jb.getString("CenterName");
    
    
    
                            String strArray[] = ServiceCenterName.split(" ");
    
                    System.out.println("String converted to String array");
    
                    //print elements of String array
                    for(int i=0; i < strArray.length; i++)
                    {
                            System.out.println(strArray[i]);
                    }
    
                ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.select_dialog_singlechoice, strArray);
    
                SearchEdittext.setThreshold(1);
                SearchEdittext.setAdapter(adapter)
    
    
                    }
                } 
                else
                {
                    Status_Response_FindStores_Landing = response.toString();
                }
    
            } catch (Exception e) {
                Log.i(TAG2, "Error in catch");
                e.printStackTrace();
            }
    
        }
    

提交回复
热议问题