2016-01-20 55 views
0

我有一個問題,在android中有沒有任何可能的方法來綁定自動完成整數值,就像我們在web應用程序中,我們解析int值和顯示名稱。任何幫助將是有益的,因爲我已經浪費了這麼多天在這個愚蠢的事情。我已經閱讀過不同的文章,他們說我不能像在網絡應用程序中那樣控制它,但應該有另一種方法來解決這個問題。 謝謝自動完成綁定值在android中完成

+0

什麼方式u加上顯示字符串值? – Brendon

回答

0

我已經使用以下。下面是我的XML

<AutoCompleteTextView 
     android:id="@+id/autoCompleteTextView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@+id/editText1" 
     android:layout_alignTop="@+id/textView3" 
     android:layout_toRightOf="@+id/textView10" 
     android:background="@drawable/buttongrey" 
     android:ems="10" 
     android:textColor="#000000" > 

    </AutoCompleteTextView> 

,這裏是我的代碼

final AutoCompleteTextView s2= (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1); 
    ArrayList<String> my_array2 = new ArrayList<String>(); 
     my_array2 = mydb.getFault(casenoproduct); 
    ArrayAdapter my_Adapter2 = new ArrayAdapter(this,android.R.layout.simple_list_item_1,my_array2); 

    s2.setAdapter(my_Adapter2); 
    s2.setOnItemClickListener(new OnItemClickListener() 
    { 
     public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) 
     { 

      fault = (String)parent.getItemAtPosition(position); 
      fault=fault.replace(" ","*"); 
     }  
    }); 

我填充我的汽車在Android數據庫完整

+0

@brendon你可以告訴 –