0

IM グリッド ビューで画像をクリックし、その中の画像を再帰的に非表示にしようとしていますが、それは起こっていません。コードは if ステートメントに達しますが、画像を非表示にできません

public class GridLayoutActivity extends Activity {

    GridView gridView;
    public Integer[] mThumbIds = {
            R.drawable.right, R.drawable.right,
            R.drawable.right, R.drawable.left,
            R.drawable.left, R.drawable.left,
            R.drawable.left, R.drawable.up,
            R.drawable.left, R.drawable.up,
            R.drawable.down, R.drawable.right,
            R.drawable.up, R.drawable.right,
            R.drawable.up
    };
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_layout);

         gridView = (GridView) findViewById(R.id.grid_view);

        // Instance of ImageAdapter Class
        gridView.setAdapter(new ImageAdapter(this));

        /**
         * On Click event for Single Gridview Item
         * */
        gridView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View v,
                    int position, long id) {

                recursive(position,v);



            }

            private void recursive(int position,View v) {
                // TODO Auto-generated method stub
                /* MobileArrayAdapter adapter=new MobileArrayAdapter(getBaseContext(), position);
                    System.out.println("Adapter set");
                    gridView.setAdapter(adapter);*/
                System.out.println(v);
                String imageName = getResources().getResourceEntryName(mThumbIds[position]);
                System.out.println(imageName);
                /*String up = getResources().getResourceEntryName(mThumbIds[position-3]);
                String down = getResources().getResourceEntryName(mThumbIds[position+3]);
                String right = getResources().getResourceEntryName(mThumbIds[position+1]);
                String left = getResources().getResourceEntryName(mThumbIds[position-1]);
                */
                if(imageName.equalsIgnoreCase("up"))//&&!down.equalsIgnoreCase("down"))
                {
                    Toast.makeText(getApplicationContext(), "UP", Toast.LENGTH_SHORT).show();
                    ImageView imageView=(ImageView)v;
                    imageView.setVisibility(View.INVISIBLE);
                    try{
                    recursive(position-3, v);
                    }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                    }
                }
                if(imageName.equalsIgnoreCase("down"))//&&!up.equalsIgnoreCase("up"))
                {
                    ImageView imageView=(ImageView)v;
                    imageView.setVisibility(View.INVISIBLE);

                }
                if(imageName.equalsIgnoreCase("left"))//&&!right.equalsIgnoreCase("right"))
                {System.out.println("M HERE");
                    ImageView imageView=(ImageView)v;
                    imageView.setVisibility(View.INVISIBLE);
                }
                if(imageName.equalsIgnoreCase("right"))//&&!left.equalsIgnoreCase("left"))
                {
                    ImageView imageView=(ImageView)v;
                    imageView.setVisibility(View.INVISIBLE);

                }



            }
        });
    }

    /*
    class MobileArrayAdapter extends ArrayAdapter
    {
        Context context2;
        int position ;
        public MobileArrayAdapter(Context context, int textViewResourceId) {
            super(context, textViewResourceId);
            // TODO Auto-generated constructor stub
             position =textViewResourceId;
             context2=context;
        }
        @Override
        public View getView(int positionn, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            ImageView imageView = new ImageView(context2);
            imageView.setImageResource(mThumbIds[position]);
            imageView.setVisibility(View.INVISIBLE);


            return super.getView(position, convertView, parent);
        }

    }*/


}
4

0 に答える 0