Note that there are some explanatory texts on larger screens.

plurals
  1. POset activities with ViewPager
    primarykey
    data
    text
    <p>I'm tring to make an app like google+ desing, with titlepager and switch between activities horizontally. I've implemnted this library for pager (https://github.com/JakeWharton/Android-ViewPagerIndicator) and it works fine. But now, I dont know how to set diferent activities.</p> <p>This is my main class</p> <pre><code>package com.rbrlnx.controles; import android.app.ActionBar; import android.app.Activity; import android.os.Bundle; import android.support.v4.view.ViewPager; import com.viewpagerindicator.TitlePageIndicator; public class ControlesDeAlcoholemiaActivity extends Activity { static final int NUMERO_DE_PAGINAS = 3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Gestion del Pagindor ViewPagerAdapter adapter = new ViewPagerAdapter( this ); ViewPager pager = (ViewPager)findViewById( R.id.viewpager ); TitlePageIndicator indicator = (TitlePageIndicator)findViewById( R.id.indicator ); pager.setAdapter( adapter ); indicator.setViewPager(pager,2); //Gestion del ActionBar ActionBar ab; } } </code></pre> <p>and this is the pageradapter</p> <pre><code>package com.rbrlnx.controles; import android.content.Context; import android.os.Parcelable; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; import com.viewpagerindicator.TitleProvider; public class ViewPagerAdapter extends PagerAdapter implements TitleProvider { private static String[] titles = new String[] { "Comunes", "Listado", "Mapa" }; private final Context context; public ViewPagerAdapter( Context context ) { this.context = context; } @Override public String getTitle( int position ) { return titles[ position ]; } @Override public int getCount() { return titles.length; } @Override public Object instantiateItem( View pager, int position ) { LinearLayout v = (LinearLayout) LayoutInflater.from(this.context).inflate(R.layout.comunes, null); if (position == 0) { v = (LinearLayout) LayoutInflater.from(this.context).inflate(R.layout.comunes, null); } else if (position == 1) { v = (LinearLayout) LayoutInflater.from(this.context).inflate(R.layout.listado, null); } else { v = (LinearLayout) LayoutInflater.from(this.context).inflate(R.layout.mapa, null); } ((ViewPager) pager).addView(v, 0); return v; } @Override public void destroyItem( View pager, int position, Object view ) { } @Override public boolean isViewFromObject( View view, Object object ) { return view.equals( object ); } @Override public void finishUpdate( View view ) {} @Override public void restoreState( Parcelable p, ClassLoader c ) {} @Override public Parcelable saveState() { return null; } @Override public void startUpdate( View view ) {} } </code></pre> <p>I can set the XML layout, but I don't know how to set the acitivy class. I think I must work with fragments but am not sure.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload