而滚动扩展列表Android的黑色背景 [英] Expandable List Android Black background while scrolling

查看:100
本文介绍了而滚动扩展列表Android的黑色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ExpandableList查看Android中挣扎。
我使用的API的演示提供的code,但我不知道如何解决我的问题。

我得到了我的观点一个白色背景,但是当我在滚动列表中它变成black..why?

我不希望这样的效果......有没有办法改变它?有没有一种方法来定制使用这种code中的列表?
我正在寻找类似this..Hope你能帮助我!
谢谢:)

 包com.example.android.apis.view;进口android.R;
进口android.app.ExpandableListActivity;
进口android.os.Bundle;
进口android.widget.ExpandableListAdapter;
进口android.widget.SimpleExpandableListAdapter;进口的java.util.ArrayList;
进口的java.util.HashMap;
进口的java.util.List;
进口的java.util.Map;
/ **
 *演示了用一个简单的基于地图的适配器支持扩展列表
 * /
公共类ExpandableList3扩展ExpandableListActivity {
    私有静态最后弦乐NAME =NAME;
    私有静态最后弦乐IS_EVEN =IS_EVEN;    私人ExpandableListAdapter mAdapter;    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);        清单<地图<字符串,字符串>> groupData =新的ArrayList<地图<字符串,字符串>>();
        清单<名单,LT;地图<字符串,字符串>>> childData =新的ArrayList<名单,LT;地图<字符串,字符串>>>();
        的for(int i = 0; I< 20;我++){
            地图<字符串,字符串> curGroupMap =新的HashMap<字符串,字符串>();
            groupData.add(curGroupMap);
            curGroupMap.put(NAME,本集团+ I);
            curGroupMap.put(?IS_EVEN,(我%2 == 0)这组连:这组奇);            清单<地图<字符串,字符串>>孩子=新的ArrayList<地图<字符串,字符串>>();
            为(中间体J = 0; J&下; 15; J ++){
                地图<字符串,字符串> curChildMap =新的HashMap<字符串,字符串>();
                children.add(curChildMap);
                curChildMap.put(NAME,孩子+ J);
                curChildMap.put(?IS_EVEN,(J%2 == 0)这孩子连:这孩子是奇);
            }
            childData.add(儿童);
        }        //设置我们的适配器        mAdapter =新SimpleExpandableListAdapter(
                本,
                groupData,
                android.R.layout.simple_expandable_list_item_1,
                新的String [] {NAME,IS_EVEN},
                新的INT [] {android.R.id.text1,android.R.id.text2},
                childData,
                R.layout.simple_expandable_list_item_3,
                新的String [] {NAME,IS_EVEN},
                新的INT [] {android.R.id.text1,android.R.id.text2}
                );        setListAdapter(mAdapter);
    }}


解决方案

添加到您的列表视图中的XML文件:

的android:cacheColorHint =#00000000

或你的Java code:

getListView()setCacheColorHint(0);

I'm struggling with the ExpandableList View in Android. I'm using the code provided in the apis demo but I don't know how to solve my problem.

I got a white background on my view but when I'm scrolling the list it turns black..why?

I don't want this effect...is there a way to change it? is there a way to customize the list using this code? I'm looking for something like this..Hope you could help me! Thank you :)

package com.example.android.apis.view;

import android.R;
import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Demonstrates expandable lists backed by a Simple Map-based adapter
 */
public class ExpandableList3 extends ExpandableListActivity {
    private static final String NAME = "NAME";
    private static final String IS_EVEN = "IS_EVEN";

    private ExpandableListAdapter mAdapter;

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

        List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
        List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
        for (int i = 0; i < 20; i++) {
            Map<String, String> curGroupMap = new HashMap<String, String>();
            groupData.add(curGroupMap);
            curGroupMap.put(NAME, "Group " + i);
            curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");

            List<Map<String, String>> children = new ArrayList<Map<String, String>>();
            for (int j = 0; j < 15; j++) {
                Map<String, String> curChildMap = new HashMap<String, String>();
                children.add(curChildMap);
                curChildMap.put(NAME, "Child " + j);
                curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
            }
            childData.add(children);
        }

        // Set up our adapter

        mAdapter = new SimpleExpandableListAdapter(
                this,
                groupData,
                android.R.layout.simple_expandable_list_item_1,
                new String[] { NAME, IS_EVEN },
                new int[] { android.R.id.text1, android.R.id.text2 },
                childData,
                R.layout.simple_expandable_list_item_3,
                new String[] { NAME, IS_EVEN },
                new int[] { android.R.id.text1, android.R.id.text2 }
                );

        setListAdapter(mAdapter);
    }

}

解决方案

Add to your listview in the xml file:

android:cacheColorHint="#00000000"

or in your Java code:

getListView().setCacheColorHint(0);

这篇关于而滚动扩展列表Android的黑色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆