本文共 879 字,大约阅读时间需要 2 分钟。
我想获取在AutoCompleteTextView中显示的被选择到的内容 然后返回给另一个活动 final AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.ac_university); String[] universities = myDbHelper.getAllUnis(db); // Print out the values to the log for(int i = 0; i < universities.length; i++) { Log.i(this.toString(), universities[i]); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, universities); textView.setAdapter(adapter); //textView.setOnItemSelectedListener(this); textView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent intent = new Intent(Main.this, Campus.class); Bundle bundle = new Bundle(); bundle.putString("university_name", arg0.getItemAtPosition(arg2).toString()); bundle.putLong("_id", arg3); intent.putExtras(bundle); startActivity(intent); }转载地址:http://arbai.baihongyu.com/