Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:19:15+00:00 2026-05-22T03:19:15+00:00

I want to know how to put tick mark on image which we click

  • 0

I want to know how to put tick mark on image which we click in grid layout.I have image of tickmark pls tell me how to put tick mark over image?

here is my code

    public class HeadshotAllPhoto extends Activity implements OnItemClickListener 
{
    ImageView bg,tickmark;
    int ht,wt;
    GridView imagegrid;
    static boolean flag = false;
    String path,filemanagerstring;
    String[] ImageNameArr;
    String filePath = null;
    String ImageName ;
    Bitmap bitmap;
    DataHelperHeadshot dbHeadshot;
    String uplaodedHeadshot;
    Cursor cursor;
    String sub_list ;
    String[] pathArr;
    Bitmap[] bmp;
    ArrayList<String> items = new ArrayList<String>();
    ImageView i;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.headshotallphoto);
        dbHeadshot = new DataHelperHeadshot(this);

        bg = (ImageView)findViewById(R.id.selectHeadshotView);      

        List<String> names = this.dbHeadshot.fetchAllHeadshot();
        StringBuilder sb = new StringBuilder();
        for (String name : names)
        { 
           name.trim();
           sb.append(",");
           sb.append(name);
        } 
        bmp = new Bitmap[SelectionHeadshot.icount+1];
        for(int p=0;p<names.size();p++)           
        {       
            if(names.get(p) !=null)
            {               
                bitmap = decodeFile(names.get(p));    
                if(bitmap!=null)
                {
                    items.add(names.get(p));                  
                    bmp[p] = bitmap;
                }
            }           
        }       
        imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
        imagegrid.setAdapter(new ImageAdapter(getApplicationContext(),bmp));
        imagegrid.setOnItemClickListener(this);      
    }

    public class ImageAdapter extends BaseAdapter
    {
        private Context mContext;       
        Bitmap[] mImageArray;        

        public ImageAdapter(Context c, Bitmap[] imgArray) 
        {
              mContext = c;
              mImageArray = imgArray;              
        }

        public int getCount() 
        {
              return mImageArray.length;
        }

        public Object getItem(int position)
        {
              return position;
        }
        public long getItemId(int position)
        {
              return position;
        }

        public View getView(int position,View convertView,ViewGroup parent)
        {
            System.gc();           
            if (convertView == null) 
            {               
                i = new ImageView(mContext);
                i.setLayoutParams(new GridView.LayoutParams(92,92));
                i.setScaleType(ImageView.ScaleType.CENTER_CROP);               
                i.setImageBitmap(mImageArray[position]);                
            }
            else 
                 i = (ImageView) convertView;           
            return i;
        }

    }

    public Bitmap decodeFile(String filePath) 
    {
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, o);

        // The new size we want to scale to
        final int REQUIRED_SIZE = 100;
        final int H = 50;

        // Find the correct scale value. It should be the power of 2.
        int width_tmp = o.outWidth, height_tmp = o.outHeight;
        int scale = 1;
        while (true) {
            if (width_tmp < REQUIRED_SIZE && height_tmp < H)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;
        }
        // Decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;        
        bitmap = BitmapFactory.decodeFile(filePath, o2);        
        return bitmap;
    }

    public void onItemClick(AdapterView<?> a, View v, final int position, long id) 
    {   
        imagegrid.getChildAt(position).setBackgroundResource(R.drawable.imgredselectmark);  
    }
}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:19:16+00:00Added an answer on May 22, 2026 at 3:19 am

    Try this code :

            private int Splash_Time_Limit = 3000;
    
            gridview.setOnItemClickListener(new OnItemClickListener(){
    
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
    
                gridview.getChildAt(arg2).setBackgroundResource(R.drawable.wrong);
    
                //  new Handler().postDelayed(new Runnable() {
                //  @Override
                //  public void run() {
                //       gridview.getChildAt(arg2).setBackgroundResource(R.drawable.tick1);
                //  }
                //  }, Splash_Time_Limit);
            }
        });
    

    If you click the Image in Grid View the images tick image will be set as Background image.

    If you want to disappear that Tick image after some times use Handler code that is commented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if really 'put' has succeeded in putting the file to
I'm starting in the Rails world and i want to know how to put
I want to know if there is any way by which I can paste
I just want to know, since I have a lot of private final static
I have a JEditorPane in a JPanel. I want to know how far from
i have the following code, and i want to know how can supress the
hi i want to know how to put the json data into html is
I want to know the global mechanism for exception handling. Like I do have
I have a CellTable where I want to put HTML-code in the cells. The
i want to know where can i put the library folder in my zend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.