• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Find View by position in a grid

nopris

Lurker
Hi all,

I followed this example Grid View | Android Developers
and built a similar code (with small alterations).

I am at this point:
Code:
gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                Toast.makeText(Main.this, mThumbVal[position].toString(), Toast.LENGTH_SHORT).show();
                if(initialized){
                	if(mThumbVal[position] == mThumbVal[clicked]){
                		Toast.makeText(Main.this, "Match", Toast.LENGTH_SHORT).show();
                		v.setVisibility(4);
                		try{
                		//View vv = (View)gridview.findViewById(clicked);
                		//vv.setVisibility(4);
                		}
                		catch(Exception ee){
                			Toast.makeText(Main.this, ee.getMessage(), Toast.LENGTH_SHORT).show();
                		}
                	}
                	initialized=false;
                }
                else{
                	initialized=true; clicked = position;
                }
            }
        });

where the commented lines are wrong and I am unsure how to fix them. What I want to do is find the image at a memorized position and hide it together with the current selected one.

Thanks in advance.
 
I copied the View in a separate var and used it after. I know it might not be efficient but it was the fastest way I could get it done.

Can anyone advise?
 
Back
Top Bottom