2017-03-13 4 views
-1

今、私は提案を表示するためにautocompleteTextviewを使用しています。私はwebserviceからデータを取得し、アダプタを設定します。AutoCompleteTextViewは動作しません

私はエラーは表示されませんが、Textviewをクリックすると、何も表示されません。その後、リストをチェックし、そのデータが含まれています。

ここに間違いを発見しますか?ここ

は私のコード

public class ListCustomerItem { 
public String CustName; 
/*public String CustLocation; 
public String CustID;*/ 

} 

--listカスタマーAdapter--

Item--

<AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/acCustomer" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/etCustomerOther" 
       android:layout_marginBottom="10dp" 
       android:layout_alignLeft="@+id/spCustomer"/> 

--class--

private static List<String> customerList; 

private class LoadCustomer extends AsyncTask<Void, Void, Void> { 
    @Override 
    protected void onPreExecute() { 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, 
       WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); 
     pBar.setVisibility(View.VISIBLE); 
     pBar.setIndeterminate(false); 
     pBar.setClickable(false); 
    } 
    @Override 
    protected Void doInBackground(Void... params) { 

     try { 
      RESTClient client = new RESTClient(URLService+"get?method=getallcustomerlist&value="); 

      client.Execute(RESTClient.RequestMethod.GET); 
      responseCustomer = client.getResponse(); 



     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     return null; 
    } 

    @Override 
    protected void onPostExecute(Void result) { 
     try{ 

      responseCustomer = responseCustomer.replace("\\\"","\""); 
      responseCustomer = responseCustomer.substring(1, responseCustomer.length() - 1); 

      JSONParser jsonParser = new JSONParser(); 
      JSONObject jsonObject = (JSONObject) jsonParser.parse(responseCustomer); 

      String Status = jsonObject.get("Status").toString(); 

      if (Status == "true"){ 
       // JSONArray structure = (JSONArray) jsonObject.get("DataList"); 
       String dataku = jsonObject.get("DataList").toString(); 

       try { 
        dataku = CRYYPT.decrypt(Enc_Pass, dataku); 
       }catch (GeneralSecurityException e){ 
        //handle error - could be due to incorrect password or tampered encryptedMsg 
       } 

       JSONParser parser = new JSONParser(); 
       JSONArray structure = (JSONArray) parser.parse(dataku); 
       customerList = new ArrayList<String>(); 
       customerList.add("--Choose--"); 
       for (int i = 0; i < structure.size(); i++) { 
        JSONObject customerlist = (JSONObject) structure.get(i); 

        customerList.add(customerlist.get("CustomerName").toString()); 
       } 
       customerList.add("Other"); 

       ArrayAdapter<String> adapter = new ArrayAdapter<String>(WorkflowActivity.this, android.R.layout.simple_list_item_1, customerList); 
       acCustomer.setAdapter(adapter); 

      }else { 

      } 
     } 
     catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); 
     pBar.setClickable(true); 
     pBar.setVisibility(View.GONE); 
    } 

} 

--listお客様です

public class ListCustomerAdapter extends ArrayAdapter<ListCustomerItem> { 
public ListCustomerAdapter(Context context, List<ListCustomerItem> items) 
{ 
    super(context, R.layout.style_fragment_list_customer, items); 
} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    ViewHolder viewHolder; 

    if(convertView == null) { 
     // inflate the GridView item layout 
     LayoutInflater inflater = LayoutInflater.from(getContext()); 
     convertView = inflater.inflate(R.layout.style_fragment_list_customer, parent, false); 

     // initialize the view holder 
     viewHolder = new ViewHolder(); 
     viewHolder.tvCustName = (TextView) convertView.findViewById(R.id.tvCustName); 
     // viewHolder.tvCustLocation = (TextView) convertView.findViewById(R.id.tvCustLocation); 

     convertView.setTag(viewHolder); 
    } else { 
     // recycle the already inflated view 
     viewHolder = (ViewHolder) convertView.getTag(); 
    } 

    // update the item view 
    ListCustomerItem item = getItem(position); 
    viewHolder.tvCustName.setText(item.CustName); 
    // viewHolder.tvCustLocation.setText(item.CustLocation); 

    return convertView; 
} 
private static class ViewHolder { 
    TextView tvCustName; 
    TextView tvCustLocation; 
} 
} 

答えて

1

AutoCompleteTextView内でandroid:completionThreshold="1"を試しましたか?

またはmAutoCompleteTextView.setThreshold(1)をAutoCompleteTextViewリファレンスと呼んでいますか?カスタムアダプタクラスで

+0

IVEは試してみましたが、それでもdidntの仕事は – gilllsss

+0

このチュートリアルに従っています。それはあなたの役に立つかもしれません。 http://android.foxykeep.com/dev/how-to-add-autocompletion-to-an-edittext – Shyamali

+0

まだ助けてくれない、申し訳ありません。 – gilllsss

0
mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView); 

カスタム・アダプタを使用してAutoCompleteTextViewを設定

mAutoCompleteTextView.setSelection(0); 
mCustomAutoFilterAdapter = new CustomAutoFilterAdapter(this,R.layout.spinner_row, yourList); 
mAutoCompleteTextView.setThreshold(1); 
mAutoCompleteTextView.setAdapter(mCustomAutoFilterAdapter); 

​​
+0

こんにちは、私はまだそれを得ることはできません、私はフィルタリングを実行し、結果を公開する必要があります。 – gilllsss

+0

コードを投稿できますか?フィルタリングに使用しますか? – Napster

+0

この[リンク]をクリックしてください(https://akshaymukadam.wordpress.com/2015/02/01/how-to-create-autocompletetextview-using-custom-filter-implementation/) – Napster

関連する問題