Question

How to get the text color of a gridview, in my app i have used black, white and red color to differentiate the text, now i need to get the color of a text in onclick, Give me some idea to get the solution.

Thanks.

Was it helpful?

Solution

set onItemClickListener to:

gridView.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                        long arg3) {
                    TextView tv = (TextView) view;
                    int color=tv.getCurrentTextColor();

                }
            });

OTHER TIPS

You can use this in OnItemClick

textView.getCurrentTextColor();

This will solve your problem:

       gridViewLocation=(GridView) findViewById(R.id.gridViewLocation);

Now set adapter:

gridViewLocation.setAdapter(new GridViewAdapter(this, MOBILE_OS));

gridViewLocation.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v,
                int position, long id) {


            TextView textView=(TextView) v.findViewById(R.id.grid_item_label);
                textView.getCurrentTextColor();



        }
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top