我有一个包含4个项目的列表视图。只要单击其中一个,就会显示一个弹出式微调器。我填充了微调器适配器,但我不知道如何显示它。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_community);
listView = (ListView)findViewById(R.id.lv_community);
list_c = getResources().getStringArray(R.array.community);
cAdapter = new ArrayAdapter<String>(Community.this,android.R.layout.simple_list_item_1,list_c);
listView.setAdapter(cAdapter);
listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position){
case 0: list_sc = getResources().getStringArray(R.array.Spr_subclass);
scAdapter = new ArrayAdapter<String>(Community.this,android.R.layout.simple_spinner_dropdown_item,list_sc);
break;
case 1: list_sc = getResources().getStringArray(R.array.Edu_subclass);
scAdapter = new ArrayAdapter<String>(Community.this,android.R.layout.simple_spinner_dropdown_item,list_sc);
break;
case 2: list_sc = getResources().getStringArray(R.array.Coo_subclass);
scAdapter = new ArrayAdapter<String>(Community.this,android.R.layout.simple_spinner_dropdown_item,list_sc);
break;
case 3: list_sc = getResources().getStringArray(R.array.Com_subclass);
scAdapter = new ArrayAdapter<String>(Community.this,android.R.layout.simple_spinner_dropdown_item,list_sc);
break;
}
}
});
}
答案 0 :(得分:1)
你可以这样做
public void showSpinnerPopUp(String[] array){
AlertDialog.Builder b = new Builder(this);
b.setTitle("Example");
b.setItems(array, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch(which){
}
}
});
b.show();
}
在项目点击
中执行此操作 showSpinnerPopUp(list_c)
;