我是一个新手android学习者。当用户选择 AutoCompleteTextView 中的项目时,我正在尝试创建 toast。我正在从 strings.xml 读取值,它工作正常,但我很困惑我如何(甚至是处理程序)我需要创建 toast。下面是我的代码 1-activity.xml
<AutoCompleteTextView android:id="@+id/myautocomplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
/>
strings.xml
<string-array name="termsarray">
<item>emulator</item>
<item>ant</item>
<item>string.xml</item>
<item>activity</item>
<item>workspace</item>
<item>adt</item>
<item>manifest.xml</item>
<item>package</item>
<item>layout</item>
<item>toast</item>
<item>adb</item>
</string-array>
//activity.java
public class TermActivity extends Activity {
String[] categories;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
categories=getResources().getStringArray(R.array.termsarray);
setContentView(R.layout.activity_term);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_dropdown_item_1line, categories);
AutoCompleteTextView textView =
(AutoCompleteTextView) findViewById(R.id.myautocomplete);
textView.setThreshold(3);
textView.setAdapter(adapter);
}