我有以下代码,我正在尝试将 链接String [] teams
到该team1Input
字段。该程序当前崩溃,我很确定我没有team1Input.getId()
正确使用。我怎么能在不接触任何 xml 的情况下做到这一点?
final AutoCompleteTextView team1Input = new AutoCompleteTextView(this);
team1Input.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, team1Input.getId(), teams);
team1Input.setAdapter(adapter);
row1.addView(team1Input);