Madhu
Madhu

Reputation: 1800

Gridview text color change in android

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.

Upvotes: 1

Views: 1090

Answers (3)

Justcurious
Justcurious

Reputation: 2299

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();



        }
    });

Upvotes: 0

Mohammad Rababah
Mohammad Rababah

Reputation: 1726

You can use this in OnItemClick

textView.getCurrentTextColor();

Upvotes: 0

vipul mittal
vipul mittal

Reputation: 17401

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();

                }
            });

Upvotes: 1

Related Questions