1. Download our Official Android App: Forums for Android!

Apps Find View by position in a grid

Discussion in 'Android Development' started by nopris, Dec 11, 2010.

  1. nopris

    nopris Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    2
    0
    5
    Hi all,

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

    I am at this point:
    Code (Text):
    1. gridview.setOnItemClickListener(new OnItemClickListener() {
    2.             public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    3.                 Toast.makeText(Main.this, mThumbVal[position].toString(), Toast.LENGTH_SHORT).show();
    4.                 if(initialized){
    5.                     if(mThumbVal[position] == mThumbVal[clicked]){
    6.                         Toast.makeText(Main.this, "Match", Toast.LENGTH_SHORT).show();
    7.                         v.setVisibility(4);
    8.                         try{
    9.                         //View vv = (View)gridview.findViewById(clicked);
    10.                         //vv.setVisibility(4);
    11.                         }
    12.                         catch(Exception ee){
    13.                             Toast.makeText(Main.this, ee.getMessage(), Toast.LENGTH_SHORT).show();
    14.                         }
    15.                     }
    16.                     initialized=false;
    17.                 }
    18.                 else{
    19.                     initialized=true; clicked = position;
    20.                 }
    21.             }
    22.         });
    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.
     

    Advertisement

  2. nopris

    nopris Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    2
    0
    5
    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?
     

Share This Page

Loading...