1 /* 2 * Copyright 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.tabcompat.lib; 18 19 import android.graphics.drawable.Drawable; 20 import android.support.v4.app.Fragment; 21 import android.support.v4.app.FragmentActivity; 22 23 /** 24 * Represents a single tab. 25 * The {@link TabHelper} initializes one of the subclasses of this based 26 * on the current platform version, upon call to {@link TabHelper#newTab(String)}() 27 */ 28 public abstract class CompatTab { 29 final FragmentActivity mActivity; 30 final String mTag; 31 CompatTab(FragmentActivity activity, String tag)32 protected CompatTab(FragmentActivity activity, String tag) { 33 mActivity = activity; 34 mTag = tag; 35 } 36 setText(int resId)37 public abstract CompatTab setText(int resId); setIcon(int resId)38 public abstract CompatTab setIcon(int resId); setTabListener(CompatTabListener callback)39 public abstract CompatTab setTabListener(CompatTabListener callback); setFragment(Fragment fragment)40 public abstract CompatTab setFragment(Fragment fragment); 41 getText()42 public abstract CharSequence getText(); getIcon()43 public abstract Drawable getIcon(); getCallback()44 public abstract CompatTabListener getCallback(); getFragment()45 public abstract Fragment getFragment(); 46 getTab()47 public abstract Object getTab(); 48 getTag()49 public String getTag() { 50 return mTag; 51 } 52 } 53