小编May*_*ank的帖子

当我使用带有listadapter的AlertDialog.Builder的setSingleChoiceItems时,单选按钮不显示

当我使用带有listadapter的AlertDialog.Builder的setSingleChoiceItems时,单选按钮不显示.如果我使用Charsequence []数组,单选按钮会显示.请看一下我正在使用的代码.提前致谢!!

公共类ExampleApp扩展Activity {

Context mContext;
ListAdapter myListAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    myListAdapter = new myListAdapter(mContext);
    AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
    alt_bld.setTitle("Select any icon");
    alt_bld.setSingleChoiceItems(myListAdapter, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            Toast.makeText(getApplicationContext(), "Selected icon = "+imageName[item], Toast.LENGTH_SHORT).show();
        }
    });
    AlertDialog alert = alt_bld.create();
    alert.show();
}

private class myListAdapter extends BaseAdapter{
    public myListAdapter(Context mContext){
}

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return imageName.length;
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android listadapter android-alertdialog

2
推荐指数
1
解决办法
4623
查看次数

标签 统计

android ×1

android-alertdialog ×1

listadapter ×1