Gestures in gallery and listview
<p>I have a gallery on the first half of layout and a listview in the second half of layout i.e gallery on top and listview bottom of the same layout.When I click on the gallery the gallery should move the listview down and appear most half of screen and when listview is clicked the gallery should move up and listview should appear most half of screen.how can i acheive that using gestures.One more condition is when i click on gallery listener it shoul go to another activity and when i click on listview it should go to another activity. pls give some ideas..
code is as follows...</p>

<pre><code>public class Layouthide_showActivity extends Activity 
//implements OnGesturePerformedListener 
{
    /** Called when the activity is first created. */

    RelativeLayout rel;
    Boolean flag=false;

     View.OnTouchListener gestureListener;
      GestureOverlayView gestures;
    private String Favtext[] = { "America's Next Top Model", "Bachelor Pad",
            "Bones", "America's Next Top Model", "Bachelor Pad", "Bones",
            "Scooby doo", "America's Next Top Model", "Bachelor Pad", "Bones",
            "America's Next Top Model", "Scooby doo", "Bachelor Pad", "Bones",
            "power puff girls", "America's Next Top Model", "Bachelor Pad",
            "Bones", "Dexter", "power puff girls" };
    int[] imageIDs = { R.drawable.img_1, R.drawable.img_1, R.drawable.img_14,
            R.drawable.img_3, R.drawable.img_4, R.drawable.img_6,
            R.drawable.img_7, R.drawable.img_9, R.drawable.img_10,
            R.drawable.img_12, R.drawable.img_13, R.drawable.img_2,
            R.drawable.ing_15, R.drawable.img_16 };
    private ImageAdapter imageAdapter;
    ListView _list;
    Gallery _gallery;
     private Gesture mGesture;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        rel = (RelativeLayout) findViewById(R.id.lin);
        _gallery = (Gallery) findViewById(R.id.gal);
        imageAdapter = new ImageAdapter(this, imageIDs);
        _gallery.setAdapter(imageAdapter);

        _list = (ListView) findViewById(R.id.listview_id);
        final ArrayAdapter&lt;String&gt; adapt = new ArrayAdapter&lt;String&gt;(this,
                android.R.layout.simple_list_item_1, Favtext);

        LayoutInflater inflater = getLayoutInflater();
        ViewGroup header = (ViewGroup) inflater.inflate(R.layout.header, _list,
                false);
        _list.addHeaderView(header, null, false);
        _list.setAdapter(adapt);
        // _list.setFocusableInTouchMode(false);
        _list.setOnItemClickListener(new OnItemClickListener() {



        @Override
        public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            Intent i= new Intent(Layouthide_showActivity.this,ListActivity.class);
            startActivity(i);
        }
         });
        /*_list.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, final boolean hasFocus) {
                if (hasFocus == true) {
                    _list.setOnItemClickListener(new OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1,
                                int arg2, long arg3) {
                            // TODO Auto-generated method stub
                            Log.i("SampleApp", "onFocusChanged() - view="
                                    + hasFocus);
                            //rel.setPadding(0, -100, 0, 0);
                        }

                    });

                }
            }
        });*/
        _gallery.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1,
                    int arg2, long arg3) {
                // TODO Auto-generated method stub
                //rel.setPadding(0, 0, 0, 0);
                Intent i= new Intent(Layouthide_showActivity.this,GalleryActivity.class);
                startActivity(i);

            }
        });

           gestures = (GestureOverlayView) findViewById(R.id.gestures);

           gestures.addOnGestureListener(new OnGestureListener() {

            @Override
            public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onGesture(GestureOverlayView overlay, MotionEvent event) {
                // TODO Auto-generated method stub
                int action=event.getAction();
                switch(event.getAction()){
            case MotionEvent.ACTION_MOVE:
                    break;
            case MotionEvent.ACTION_UP:
                if((action == MotionEvent.ACTION_UP) ){
                gestures.setPadding(0, -100, 0, 0);
                }
                else if((action == MotionEvent.ACTION_DOWN) ||
                           (action == MotionEvent.ACTION_POINTER_1_DOWN) ||
                           (action == MotionEvent.ACTION_POINTER_2_DOWN) ||
                           (action == MotionEvent.ACTION_MOVE)){
                    gestures.setPadding(0, 0, 0, 0);
           }
                break;
            case MotionEvent.ACTION_DOWN:
                gestures.setPadding(0, 0, 0, 0);
                    break;

            }
                //int x = (int)event.getX();

                //int y = (int)event.getY();

                int y=0;
                float top    = 0.0F;

                float bottom = 450.0F;
                if(y&lt;450){
                    gestures.setPadding(0, -100, 0, 0);
                }

//          else if(y&gt;450)
//          {
//              gestures.setPadding(0, 0, 0, -100);
//          }
        }
           });
}
public class ImageAdapter extends BaseAdapter {
    Context mContext;
    int[] image;

    public ImageAdapter(Context c, int[] imageIDs) {
        mContext = c;
        image = imageIDs;
        // mImages = new ImageView[imageIDs.length];
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return image.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setPadding(5, 5, 5, 5);
            imageView.setLayoutParams(new Gallery.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

        } else {
            imageView = (ImageView) convertView;
        }
        imageView.setImageResource(image[position]);
        // imageView.setOnClickListener(Layouthide_showActivity.this);
        // imageView.setOnTouchListener(gestureListener);
        // imageView.setOnClickListener(new OnClickListener() {

        // @Override
        // public void onClick(View v) {
        // TODO Auto-generated method stub
        // rel.clearFocus();
        // rel.setPadding(0, 0, 0, 0);
        // }
        // });

        return imageView;
    }
}
</code></pre>
