我在下面的代码中遇到的问题:
自动完成功能正常并显示电话和姓名,但我只需要电话在选择后放置一个文本视图。
请。
public class SendingSMSActivity extends Activity{
private int mCount;
private AutoCompleteTextView actv;
private ArrayList<String> mcurrentssFistLastName_PhoneList = null;
// private ArrayList<String> mcurrentssFistLastNameList = null;
AutoCompleteTextView PhoneNumberAutoComp;
MultiAutoCompleteTextView PhoneNumberMultiAutoComp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sending_sms_activity);
PhoneNumberAutoComp=(AutoCompleteTextView)findViewById(R.id.aCT_phone_number);
PhoneNumberMultiAutoComp=(MultiAutoCompleteTextView)findViewById(R.id.multiCompTextView);
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,init());
PhoneNumberAutoComp.setAdapter(adapter);
PhoneNumberAutoComp.setThreshold(1);
PhoneNumberMultiAutoComp.setAdapter(adapter);
PhoneNumberMultiAutoComp.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
private ArrayList<String> init(){
mcurrentssFistLastName_PhoneList = new ArrayList<String>();
//mcurrentssFistLastNameList = new ArrayList<String>();
InnerDB db = new InnerDB(SendingSMSActivity.this);
final ArrayList<String> sPhoneList = db.getAllPhoneNumber();
final ArrayList<String> sFirstLastNameList = db.getAllSFirstName();
mCount = sPhoneList.size();
for(int i = 0; i < mCount; i ++){
mcurrentssFistLastName_PhoneList.add(sFirstLastNameList.get(i) +" " +sPhoneList.get(i));
//mcurrentssFistLastNameList.add(sFirstLastNameList.get(i));
}
return mcurrentssFistLastName_PhoneList;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
}
}