2016-01-20 65 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你可以告诉 –