project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/TestActivity.java
author Medo <smaxein@googlemail.com>
Mon, 16 Jul 2012 20:16:03 +0200
changeset 7330 867e4fda496e
child 7332 3f2e130f9715
permissions -rw-r--r--
Hedgeroid: Layout experiments for the lobby page

package org.hedgewars.hedgeroid.netplay;

import org.hedgewars.hedgeroid.R;

import android.os.Bundle;
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.ViewPager;

public class TestActivity extends FragmentActivity {
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_lobby_paged);
		ViewPager pager = (ViewPager)findViewById(R.id.pager);
		pager.setAdapter(new Adapter(getSupportFragmentManager()));
	}
	
	private static class Adapter extends FragmentPagerAdapter {
		public Adapter(FragmentManager mgr) {
			super(mgr);
		}
		
		@Override
		public int getCount() {
			return 3;
		}
		
		@Override
		public Fragment getItem(int arg0) {
			switch(arg0) {
			case 0: return new RoomlistFragment();
			case 1: return new LobbyChatFragment();
			case 2: return new PlayerlistFragment();
			default: throw new IndexOutOfBoundsException();
			}
		}
	}
}