AutoCompleteTextView
无效。我是Android的初学者。我在模拟器中没有错误
我的代码如下:
package com.example.stackflow_test2;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
AutoCompleteTextView act;
String[] country={"France ","USA","Bangladesh","Canada","Other"};
ArrayAdapter<String> adapter;
EditText et1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText)findViewById(R.id.editText1);
Toast.makeText(getApplicationContext(), et1.getText().toString(), Toast.LENGTH_LONG).show();
//et1.setEnabled(false);
act=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, country);
}
}
答案 0 :(得分:0)
尝试这一步........
act.setAdapter(adapter);