Question

My ListView contains items that are different text colors. I need to grab the color state of each item to to be saved within the onSaveInstanceState of my fragment.

    ListView lvItems = (ListView) getActivity().findViewById(R.id.lvItems);
    lvItemsArray.add("Testing1234");

    lvItemsAdapter = new ListViewAdapter(getActivity(), lvItemsArray);
    lvItems.setAdapter(lvItemsAdapter);
Was it helpful?

Solution 2

Found it from another user on here, thanks.

    View view = ListAdapter.getView(0, null, null);
    TextView textView = (TextView) view.findViewById(R.id.myitemRow);
    ColorStateList mlist = textView.getTextColors();
    int color = mlist.getDefaultColor();

OTHER TIPS

LitView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
                   Log.d("TextView",""+arg1.TextView.getTextcolor());
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top