【问题标题】:@andorid In alertDialog custom listview, background color comes to black. I want white@andorid 在 alertDialog 自定义列表视图中,背景颜色变为黑色。我要白色
【发布时间】:2012-07-11 13:04:03
【问题描述】:

我正在尝试制作自定义列表视图 AlertDialog。但是Dialog的背景颜色是黑色的。

当我滑动列表时,背景颜色变为白色。我不想让我的 Dialog 的

背景黑色。什么问题?

btn_right.setOnClickListener(new Button.OnClickListener(){
        @Override
        public void onClick(View v){
            Dialog dialog2 = new Dialog(context); 
            ListView modeList = new ListView(context); 
            AlertDialog.Builder builder = new AlertDialog.Builder(context); 
            SectionedAdapter adapter;  //custom adapter
            adapter = new SectionedAdapter(context);
                builder.setTitle("list"); 
                builder.setView(modeList);          
                adapter.addSection("7th", new ArrayAdapter<String>(context,
                        R.layout.member_list, R.id.member_text, stringList));
                modeList.setAdapter(adapter); 

                dialog2 = builder.create();
                dialog2.show(); 

【问题讨论】:

  • 在列表视图中添加 android:cacheColorHint="#00000000"

标签: android listview android-alertdialog


【解决方案1】:

添加以下代码:

android:cacheColorHint="#00000000" 在列表视图中

listview.setCacheColorHint(0);

【讨论】:

    【解决方案2】:

    使用此代码:

    modeList.setCacheColorHint(0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2019-10-12
      • 1970-01-01
      相关资源
      最近更新 更多