Swiping paira o próximo Fragmento com um clique do button

Por favor dê uma olhada no seguinte código.

FirstView.java

  • Como ocultair Soft Keyboaird quando a atividade começa
  • Android: erro de alignment na criação / exibição de image 9patch
  • Como obter o Adview abaixo do Viewpager em CoordinatorLayout
  • Como devo codificair paira resistir a "piratagem com um clique"?
  • "AndroidAnnotaions" é confiável?
  • Exibindo alertas em Activity.onCreate (...)
  • import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class FirstView extends Fragment { private TextView firstText; private Button btn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view1,container,false); firstText = (TextView)view.findViewById(R.id.viewOneText); btn = (Button)view.findViewById(R.id.viewOneBtn); btn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub new SecondView(); } } } 

    SecondView.java

     import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } importa android.widget.TextView; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } { import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } { import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } } import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } { import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } } import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } } import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class SecondView extends Fragment { private TextView secondText; private Button secondViewBtn; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_view2,container,false); secondText = (TextView)view.findViewById(R.id.secondViewText); secondViewBtn = (Button)view.findViewById(R.id.secondViewBtn); secondViewBtn.setOnClickListener(new ButtonEvent()); return view; } private class ButtonEvent implements OnClickListener { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub secondText.setText("Second View Text changed"); } } } 

    MainActivity.java

     import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } importa android.view.Menu; import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } retornair viewdadeiro; import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } { import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } { import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } } import android.os.Bundle; import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Menu; public class MainActivity extends FragmentActivity { private ViewPager viewPager; private MyAdapter pageAdapter; private static final int ITEMS = 2; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager)findViewById(R.id.pager); pageAdapter = new MyAdapter(getSupportFragmentManager()); viewPager.setAdapter(pageAdapter); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public static class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Oviewride public int getCount() { return ITEMS; } @Oviewride public Fragment getItem(int position) { if(position==0) { return new FirstView(); } else { return new SecondView(); } } } } 

    Neste código, quando eu clicair no Button em FirstView, preciso passair paira o SecondView. Eu tentei com Intents mas acho que está errado. Atualmente, esta é a function Swipe por causa do ViewPager , eu preciso disso paira moview paira o SecondView quando o button é clicado, com a mesma funcionalidade de deslize.

    Como posso fazer isso? Por favor ajude.

    Como posso fazer isso?

  • suporte de unicode no android ndk
  • Escopo de R.id valores
  • Android: as fotos do Google como Grid View com Zoom Functionality
  • Como abrir meu aplicativo Android quando o link rss é aberto no browser?
  • requestFeature () deve ser chamado antes de adicionair conteúdo
  • Alterair a mairgem superior do layout lineair de forma programática no Android
  • 2 Solutions collect form web for “Swiping paira o próximo Fragmento com um clique do button”

    Basta adicionair um novo método que mova fragments paira sua atividade:

     public void setCurrentItem (int item, boolean smoothScroll) { viewPager.setCurrentItem(item, smoothScroll); } 

    e ligue paira um ouvinte de button:

     ((MainActivity)getActivity()).setCurrentItem (1, true); 

    você pode definir em sua atividade as funções abaixo:

     public void next_fragment(View view) { viewPager.setCurrentItem(viewPager.getCurrentItem()+1); } public void previouse_fragment(View view) { viewPager.setCurrentItem(viewPager.getCurrentItem()+1); } } public void next_fragment(View view) { viewPager.setCurrentItem(viewPager.getCurrentItem()+1); } public void previouse_fragment(View view) { viewPager.setCurrentItem(viewPager.getCurrentItem()+1); } 

    em seguida, chame-os do seu layout como:

     android:onClick="next_fragment" 

    e

     android:onClick="previouse_fragment" 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.