Giter Site home page Giter Site logo

tabhostview's Introduction

TabHostView

a simple TabHostView for android #usage ##1、created by xml like:

 <com.seek.tabhostview.TabHostView
        android:id="@+id/tab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="10sp"
        android:textColor="@color/tab_text_color"
        seek:dividerEnabled="true"
        seek:dividerWidth="1dp"
        seek:topLineHeigh="1dp">
    </com.seek.tabhostview.TabHostView>

activity_main.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:seek="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">
    <FrameLayout
        android:id="@+id/container"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"></FrameLayout>
    <com.seek.tabhostview.TabHostView
        android:id="@+id/tab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="10sp"
        android:textColor="@color/tab_text_color"
       >
    </com.seek.tabhostview.TabHostView>

</LinearLayout>

##2、then:

tabHostView.addFragments(R.id.container,fragments,this);

MainActivity.java :

public class MainActivity extends AppCompatActivity implements TabHostView.TabDataProvider {

    private TabHostView tabHostView;

    private int[] resId = new int[]{R.drawable.tab_main,R.drawable.tab_dis,R.drawable.tab_me};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tabHostView = (TabHostView) findViewById(R.id.tab);
        List<Fragment> fragments = new ArrayList<>(3);
        for (int i=0;i<3;i++){
            fragments.add(TestFragment.newInstance("hi,i am fragment "+i));
        }
        tabHostView.addFragments(R.id.container,fragments,this);
        tabHostView.setTabTextSize(14);
    }

    @Override
    public int getTabIconDrawable(int position) {
        return resId[position];
    }

    @Override
    public String getTabText(int position) {
        return getResources().getStringArray(R.array.tabStrs)[position];
    }
}

if you have any quetions,contact me by [email protected]

tabhostview's People

Contributors

gru110110110 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.