سؤال

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.

هل كانت مفيدة؟

المحلول

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

                }
            });

نصائح أخرى

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



        }
    });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top