微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用android.support.v4.app.ListFragment时,列表的背景颜色在滚动时变为白色;

我正面临一个严峻的问题.我正在尝试在滚动时更改列表的背景颜色(透明)但无法执行此操作.我尝试通过xml的listView以及代码进行更改.但在两个条件列表背景变成白色.我正在使用 android.support.v4.app.ListFragment;和FragmentPagerAdapter.

我想更改列表滚动时间颜色更改.为此我正在使用以下代码.

public static class ArrayListFragment extends ListFragment {
    int mNum;
    /**
     * Create a new instance of CountingFragment,providing "num"
     * as an argument.
     */
    static ArrayListFragment newInstance(int num) {
        ArrayListFragment f = new ArrayListFragment();
        // Supply num input as an argument.
        Bundle args = new Bundle();
        args.putInt("num",num);
        f.setArguments(args);

        return f;
    }
    /**
     * When creating,retrieve this instance's number from its arguments.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mNum = getArguments() != null ? getArguments().getInt("num") : 1;
    }

    /**
     * The Fragment's UI is just a simple text view showing its
     * instance number.
     */
    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_pager_list,container,false);
        //v.setBackgroundResource(R.drawable.background);
        View tv = v.findViewById(R.id.text);

        ((TextView)tv).setText(frameName());


        return v;
    }

   // @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setlistadapter(new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_checked,RishavArraylist() ));

    }

请告诉我如何在运行时更改滚动列表的背景?谢谢.

解决方法

请查看Google的 this blog post,特别是与XML有关的部分;
android:cacheColorHint="#00000000"

原文地址:https://www.jb51.cc/android/316181.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐