Tuesday, June 14, 2016

ANDROID TAB NAVIGATION




ANDROID TAB NAVIGATION


 
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;


public class AndroidTabLayoutActivity extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_android_tab_layout);
        TabHost tabHost = getTabHost();
       
        // Tab for Insert new Element
        TabSpec photospec = tabHost.newTabSpec("Insert");
        // setting Title and Icon for the Tab
        photospec.setIndicator("Insert", getResources().getDrawable(R.drawable.tick_icon));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);
        
        // Tab For to view
        TabSpec songspec = tabHost.newTabSpec("View");       
        songspec.setIndicator("View", getResources().getDrawable(R.drawable.minutes_icon1));
        Intent songsIntent = new Intent(this, SongsActivity.class);
        songspec.setContent(songsIntent);
        
        // Tab for delete
        TabSpec videospec = tabHost.newTabSpec("Delete");
        videospec.setIndicator("Delete", getResources().getDrawable(R.drawable.question_icon1));
        Intent videosIntent = new Intent(this, VideosActivity.class);
        videospec.setContent(videosIntent);
        
        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab
        tabHost.addTab(songspec); // Adding songs tab
        tabHost.addTab(videospec); // Adding videos tab
       
    }



}

No comments:

Post a Comment