0
这里是我的代码:如何在排序时在Android中添加标题栏?
public class MainActivity extends Activity {
Spinner spin;
TextView tex;
String[] country = {"A", "Afghanistan", "Albania", "Etc"};// A to Z country names
String[] code = {"+93", "+91", "Etc"}; // A to Z country Code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spin = (Spinner)findViewById(R.id.spinner1);
tex = (TextView)findViewById(R.id.tex);
ArrayAdapter aa1 = new ArrayAdapter(this, android.R.layout.simple_spinner_item, country);
aa1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setPrompt("Select the Country");
spin.setAdapter(aa1);
spin.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
tex.setText(code[arg2]);
// tex.setText(country[arg2]);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
}
我想显示该国在上微调字母顺序列表。在此之前,它应该显示A,B,C直到Z.但是这个A到Z必须是微调列表中的不可选模式。我怎样才能做到这一点?
我试试这个,但我得到错误。你能告诉我什么是等等等? – user1742971 2013-02-22 06:24:38
只是Google'Android custom arrayadapter',你可以找到几个关于如何构建一个自定义适配器的教程,并且在你理解了那个部分之后,回到这里并重新阅读我给出的答案;) – Budius 2013-02-22 09:35:40