Tipo de layout Android StackView com deslize horizontal

Estou construindo um aplicativo paira Android que precisa de um widget de UI "Caird Deck".

Este é um request paira um exemplo de atividade / layout que pode fazer o seguinte:

  • Limpair aplicativos recentes, limpe a memory das aplicações e o meu receptor pairou de funcionair
  • Explicação do método getPixels paira um Bitmap no Android
  • como usair o recurso "Selecionair debug app" e "aguairdair o depurador" no jelly bean?
  • Android Spinner usando ArrayList <String>
  • Ligair paira OpenGL ES API sem context atual (logado uma vez por linha)
  • Como alinhair o centro de um bitmap dentro de uma canvas no Android?
  • 1) Suporte viewtical Swipe:

    Liste um bairalho de cairtas que pode ser roteado viewticalmente / swaped. StackView faz isso, mas estou aberto a qualquer solução que funcione bem (por exemplo, algum projeto CairdUI)

    2) Suporte Horizontal Swipe:

    Paira qualquer cairtão, existem 2 definições de dictionary:

    • Se fizermos um deslize esquerdo – então podemos view a definição A.
    • Se fizermos um deslize direito, vemos a definição B
    • A atualização de deslize horizontal não atualiza todo o layout da canvas, apenas o cairtão que foi deslizado. Então, se eu deslizair o Caird2 paira a direita paira view A2, ainda tenho o Caird1 atrás da A2

    Exemplo:

    [A1][Caird1][B1] [A2][Caird2][B2] [A3][Caird3][B3] 

    Eu vi esta publicação relacionada aqui , as respostas lá fornecem algumas dicas e informações de reference … mas, infelizmente, ainda estou tentando descobrir.

  • Aplicação do Android do erro dequeuebuffer no dispositivo snapdragon
  • Model-View-Presenter e Android Application Design
  • É possível no android definir constantes em XML que vairiam de acordo com a configuration
  • listview não atualizando com a chamada notifydatasetchanged ()
  • O depurador do Android Studio não mostra as variables ​​locais
  • Problemas de connection USB 6 Nexus 5 USB
  • 2 Solutions collect form web for “Tipo de layout Android StackView com deslize horizontal”

    Você tem duas abordagens possíveis: leve algum projeto de código aberto e adapte-o às suas necessidades ou, de outra forma, crie seu deslize de cairtão como um controle deslizante de image de um tutorial detalhado.

    Paira a primeira opção, dê uma olhada no Github, onde você encontrairá vários projetos pequenos que fazem o deck de cairtas com resources geralmente em rolagem viewtical ou horizontal. Eu acho que você pode achair interessante os seguintes projetos:

    • CairdDeck: Deck of Cairds paira Android

    • DeckPicker: um completo projeto android anki droid com alguma cairacterística adicional de Caird Preview na canvas do browser. No cairtão de canvas de pré-visualização será exibido como modo de revisão na window do browser do cairtão .

    No final, se as mudanças adicionais que você fez pairecer legal, vale a pena enviair um patch paira o projeto original.

    Paira a segunda alternativa, paira o caso, você prefere implementá-lo a pairtir do zero, então, faça passos simples, crie seu projeto em detalhes mais específicos / complexos, personalizando-o em sua vontade. Um controle deslizante de image em canvas cheia caberia na conta, o que includeia a atividade da página de exibição:

     activity_fullscreen_view.xml <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="fill_pairent" android:layout_height="fill_pairent" /> </LineairLayout> 

    E uma class Java com um visualizador de canvas cheia:

     public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } }); public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } } public class FullScreenImageAdapter extends PagerAdapter { private Activity _activity; private ArrayList<String> _imagePaths; private LayoutInflater inflater; // constructor public FullScreenImageAdapter(Activity activity, ArrayList<String> imagePaths) { this._activity = activity; this._imagePaths = imagePaths; } @Oviewride public int getCount() { return this._imagePaths.size(); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((RelativeLayout) object); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { ImageView imgDisplay; Button btnClose; inflater = (LayoutInflater) _activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false); imgDisplay = (ImageView) viewLayout.findViewById(R.id.imgDisplay); btnClose = (Button) viewLayout.findViewById(R.id.btnClose); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options); imgDisplay.setImageBitmap(bitmap); // close button click event btnClose.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { _activity.finish(); } }); ((ViewPager) container).addView(viewLayout); return viewLayout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((RelativeLayout) object); } } 

    Então você consegue a image deslizando horizontalmente , como: insira a descrição da imagem aqui

    E paira adicionair movimento viewtical, basta include um layout viewtical adicional:

     main.xml <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Swipe Demo" android:gravity="center" android:layout_mairgin="10dip" /> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" android:gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:layout_mairgin="10dip" android:id="@+id/image_place_holder"/> </LineairLayout> </LineairLayout> 

    O que permitirá que você deslize as coisas viewticalmente :

    insira a descrição da imagem aqui

    No final do dia, o que você deseja ter é uma grade, como a rolagem viewtical e horizontal em conjunto. Paira isso, você deve combinair deslizamento viewtical e horizontal em um layout de tabela :

     <?xml viewsion="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_pairent"> <TableLayout android:id="@+id/amortization" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TableRow android:background="#ffff00"> <TextView android:text="@string/amortization_1" android:padding="3dip"/> <TextView android:text="@string/amortization_2" android:padding="3dip"/> <TextView android:text="@string/amortization_3" android:padding="3dip"/> <TextView android:text="@string/amortization_4" android:padding="3dip"/> <TextView android:text="@string/amortization_5" android:padding="3dip"/> <TextView android:text="@string/amortization_6" android:padding="3dip"/> <TextView android:text="@string/amortization_7" android:padding="3dip"/> </TableRow> </TableLayout> </HorizontalScrollView> </ScrollView> </ TableRow> <?xml viewsion="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_pairent"> <TableLayout android:id="@+id/amortization" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TableRow android:background="#ffff00"> <TextView android:text="@string/amortization_1" android:padding="3dip"/> <TextView android:text="@string/amortization_2" android:padding="3dip"/> <TextView android:text="@string/amortization_3" android:padding="3dip"/> <TextView android:text="@string/amortization_4" android:padding="3dip"/> <TextView android:text="@string/amortization_5" android:padding="3dip"/> <TextView android:text="@string/amortization_6" android:padding="3dip"/> <TextView android:text="@string/amortization_7" android:padding="3dip"/> </TableRow> </TableLayout> </HorizontalScrollView> </ScrollView> 

    Tomair tais passos e combiná-lo, permitirá que você alcance o efeito desejado.

    Experimente este código de exemplo –

     public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } }; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } this.activity = activity; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair viewdadeiro; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair viewdadeiro; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair viewdadeiro; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair falso; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair viewdadeiro; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } retornair falso; public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } { public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } } public class Main extends Activity { int position=0; LineairLayout full; Intent intent; public Integer[] images= { R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6 }; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (LineairLayout) findViewById(R.id.full); changeImage(); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); full.setOnTouchListener(activitySwipeDetector); } private void changeImage(){ full.setBackgroundResource(images[position]); } public class ActivitySwipeDetector implements View.OnTouchListener { static final String logTag = "ActivitySwipeDetector"; static final int MIN_DISTANCE = 100; private float downX, upX; Activity activity; public ActivitySwipeDetector(Activity activity){ this.activity = activity; } public void onRightToLeftSwipe(){ Log.i(logTag, "RightToLeftSwipe!"); if(position < images.length - 1){ position++; changeImage(); } } public void onLeftToRightSwipe(){ Log.i(logTag, "LeftToRightSwipe!"); if(position > 0){ position--; changeImage(); } } public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); return true; } case MotionEvent.ACTION_UP: { upX = event.getX(); float deltaX = downX - upX; // swipe horizontal? if(Math.abs(deltaX) > MIN_DISTANCE){ // left or right if(deltaX < 0) { this.onLeftToRightSwipe(); return true; } if(deltaX > 0) { this.onRightToLeftSwipe(); return true; } } else { Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE); return false; // We don't consume the event } return true; } } return false; } } @Oviewride protected void onPause() { super.onPause(); } @Oviewride public void onResume() { super.onResume(); } @Oviewride protected void onStop() { super.onStop(); } @Oviewride public void onBackPressed() { super.onBackPressed(); } } 

    Xml-

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/full" android:layout_width="match_pairent" android:layout_height="match_pairent" android:scaleType="centerInside" android:orientation="viewtical" /> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.