0

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);
zeroprobe
  • 580
  • 1
  • 8
  • 19
  • try this [link](https://developer.android.com/reference/android/widget/TextView.html#getCurrentTextColor()) – bGorle Apr 11 '14 at 12:23

2 Answers2

0

LitView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
                   Log.d("TextView",""+arg1.TextView.getTextcolor());
    });
  • Obviously you are adding some text get like thisa –  Apr 11 '14 at 13:56
  • To confirm I'm not clicking the list view. I need something to parse through it to check the text color of each item. So I wouldn't be using onItemClick – zeroprobe Apr 11 '14 at 16:46
0

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();
zeroprobe
  • 580
  • 1
  • 8
  • 19