Rvg*_*2ky 7 android arraylist android-layout android-listview android-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() ));
}
Run Code Online (Sandbox Code Playgroud)
请告诉我如何在运行时更改滚动列表的背景?谢谢.
Oce*_*ife 14
看看谷歌的这篇博文,特别是关于XML的部分;
android:cacheColorHint="#00000000"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2800 次 |
| 最近记录: |