我正面临一个关键问题。我正在尝试在滚动时更改列表的背景颜色(透明),但无法做到。我试图通过 listView 的 xml 以及代码进行更改。但在这两种情况下,列表背景都变为白色。我正在使用 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() ));
}
请告诉我如何在运行时更改滚动列表的背景?谢谢你。