I'm facing a critical problem. I'm trying to change background color (transparent) of list in scrolling time but unable to do it. I tried to change is by xml of listView as well as by code too. but in both condition list background become white. I'm using android.support.v4.app.ListFragment; and FragmentPagerAdapter.
I wanna change list scroll time color change. for this i'm using following code.
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() ));
}
Please tell me how i can change background of scrolling list at run time?? Thank you.
Take a look at this blog post from Google in particular the portion of XML pertaining to;
android:cacheColorHint="#00000000"
We have plenty of options for this problem, you can set the background as transparent through programming like
yourlistview.setCacheColorHint(Color.TRANSPARENT);
or through xml
android:cacheColorHint="@android:color/transparent"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With