Portal Android - Comunidade de Desenvolvedores Android
http://www.portalandroid.org/comunidade/

Arrastar para uma Activity
http://www.portalandroid.org/comunidade/viewtopic.php?f=44&t=22707
Página 1 de 1

Autor:  hugosouza [ 30 Nov 2012, 15:58 ]
Assunto do Tópico:  Arrastar para uma Activity

Moçada, ja pesquisei de tudo quanto é forma no google e não encontro algo sobre isso.
Estava precisando de alguma informação, tutorial ou dica de como posso fazer como vários apps android fazem, ao arrastar o dedo na tela para um determinado lado ele tras junto a proxima tela (activity).
alguem sabe como se faz?

Autor:  rafaeldecker [ 03 Dez 2012, 10:09 ]
Assunto do Tópico:  Re: Arrastar para uma Activity

Olá Hugo.

Dá uma olhada nessa biblioteca: https://github.com/JakeWharton/Android- ... rIndicator

Acho que é isso que estás precisando.

Abraço

Autor:  uchiha itachi-san [ 18 Jun 2013, 22:43 ]
Assunto do Tópico:  Re: Arrastar para uma Activity

layout1.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#333333"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:text="Tela 1"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="wrap_content"
        android:id="@+id/textView1"
        android:layout_height="wrap_content">
</TextView>
    <ListView
        android:id="@+id/listView1"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
</ListView>
    <TextView
        android:text="Tela 2"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="wrap_content"
        android:id="@+id/textView2"
        android:layout_height="wrap_content">
</TextView>
</LinearLayout>


layout2.xml



<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00FF00"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:text="Tela 2"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="wrap_content"
        android:id="@+id/textView1"
        android:layout_height="wrap_content">
</TextView>
    <EditText
        android:id="@+id/editText1"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:password="true"
        android:maxLength="14">

    </EditText>

    <Button
        android:text="VAI!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="vai"/>

</LinearLayout>


layout3.xml



<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#0000FF"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:text="Tela 3"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="wrap_content"
        android:id="@+id/textView1"
        android:layout_height="wrap_content">

    </TextView>
</LinearLayout>


MainActivity.java


import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {
private ViewPager awesomePager;
private static int NUM_AWESOME_VIEWS = 4;
private Context cxt;
private AwesomePagerAdapter awesomeAdapter;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cxt = this;

awesomeAdapter = new AwesomePagerAdapter();
awesomePager = (ViewPager) findViewById(R.id.awesomepager);
awesomePager.setAdapter(awesomeAdapter);
}

private class AwesomePagerAdapter extends PagerAdapter {

private int[] layouts = {R.layout.layout1, R.layout.layout2, R.layout.layout3, R.layout.main};

@Override
public int getCount() {
return NUM_AWESOME_VIEWS;
}

/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate()}
*
* @param container
*            The containing View in which the page will be shown.
* @param position
*            The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
*         need to be a View, but can be some other container of the
*         page.
*/

@Override
public Object instantiateItem(View collection, int position) {
Log.d("NGVL", "instantiateItem");
View v = LayoutInflater.from(cxt).inflate(layouts[position], null);
((ViewPager) collection).addView(v, 0);

if (position == 0){
List<String> nomes = new ArrayList<String>();
        for (int i = 0; i < 1000; i++) {
        nomes.add("Pessoa "+ i);
        }
        ListView lst = (ListView)findViewById(R.id.listView1);
        lst.setAdapter(new ArrayAdapter<String>(cxt, android.R.layout.simple_list_item_1, nomes));
            }

            return v;
            }

            /**
            * Remove a page for the given position. The adapter is responsible for
            * removing the view from its container, although it only must ensure
            * this is done by the time it returns from {@link #finishUpdate()}.
            *
            * @param container
            *            The containing View from which the page will be removed.
            * @param position
            *            The page position to be removed.
            * @param object
            *            The same object that was returned by
            *            {@link #instantiateItem(View, int)}.
            */

            @Override
            public void destroyItem(View collection, int position, Object view) {
            ((ViewPager) collection).removeView((View)view);
            Log.d("NGVL", "destroyItem");
            }

            @Override
            public boolean isViewFromObject(View view, Object object) {
            Log.d("NGVL", "isViewFromObject");
            return view == ((View) object);
            }

            /**
            * Called when the a change in the shown pages has been completed. At
            * this point you must ensure that all of the pages have actually been
            * added or removed from the container as appropriate.
            *
            * @param container
            *            The containing View which is displaying this adapter's
            *            page views.
            */

            @Override
            public void finishUpdate(View arg0) {
            Log.d("NGVL", "finishUpdate");
            }

            @Override
            public void restoreState(Parcelable arg0, ClassLoader arg1) {
            Log.d("NGVL", "restoreState");
            }

            @Override
            public Parcelable saveState() {
            Log.d("NGVL", "saveState");
            return null;
            }

            /**
            * Called when a change in the shown pages is going to start being made.
            * @param container The containing View which is displaying this adapter's
            * page views.
            */

            @Override
            public void startUpdate(View arg0) {
            Log.d("NGVL", "startUpdate");
            }

            }

            }

Página 1 de 1 Todos os Horários estão como UTC - 2 horas [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/