Im trying to add a autocomplete and the set an itemItemSelectListener in that Button clickevent
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,new ArrayList<String>());
//This is working fine------------------------------------------
editPhoneNum.setThreshold(1);
editPhoneNum.setAdapter(adapter);
editPhoneNum.setOnItemSelectedListener(this);
editPhoneNum.setOnItemClickListener(this);
//---------------------------------------------------------------
AddCont_btn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Counter++;
AutoCompleteTextView = new AutoCompleteTextView(sentsms.this);
AutoCompleteTextView.setThreshold(1);
AutoCompleteTextView.setOnItemSelectedListener(sentsms.this); //<--This doesn't work
AutoCompleteTextView.setAdapter(adapter);
rel_lay.addView(AutoCompleteTextView);
}
});
how to resolve this problem Thanks guys..!!!!
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
// TODO Auto-generated method stub
Log.d("AutocompleteContacts"," Name:" + arg0.getItemAtPosition(arg2) + "\n Number:"+ toNumberValue);
}
XMl rel_lay is a LinearLayout
<LinearLayout
android:id="@+id/rel_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/addCont1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter Frnds Name"
android:text="" >
</AutoCompleteTextView>
</LinearLayout>
</LinearLayout>
This method is not called when item got selected by AutoCompleteTextView
remove the autocomplete from the rel_lay from xml file
and do the necessary steps inside the