我试图在android studio中制作自动完成文本。当我把编码和运行应用程序。什么都没发生!我接受了源代码,并且完全没有发生任何事情。也许我在代码中犯了一些错误,因为我是初学者。
这是我的代码
package my.wedee.com.taskactivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
AutoCompleteTextView Airport;
String[] airport = {"India", "China", "Australia", "New Zealand", "England", "Pakistan"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//initiate an auto complete text view
Airport = (AutoCompleteTextView) findViewById(R.id.task_airport_list);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, airport);
Airport.setAdapter(adapter);
Airport.setThreshold(1);//start searching from 1 character
Airport.setAdapter(adapter); //set the adapter for displaying country name list
}
}
TQ
答案 0 :(得分:0)
转到文件并点击invalidate cache / restart,这肯定会有效..