android, Tutorial 029, UI, Tab

August 15, 2011   ·   0 Comments

android, Tutorial 029, UI, Tab

package com.powenko.Tutorial_UI_Tab;

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

public class Tutorial_UI_TabActivity extends TabActivity {
    /** Called when the activity is first created. */
	private TabHost tabHost;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        tabHost = getTabHost();
      //  Intent mtab1 = new Intent(this,info.class);      s
        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("tab1", getResources().getDrawable(R.drawable.icon ))
                .setContent(new Intent(this, info.class)));

        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("tab2", getResources().getDrawable(R.drawable.icon))
                .setContent(new Intent(this, info.class)));

        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("tab3", getResources().getDrawable(R.drawable.icon))
                .setContent(new Intent(this, info.class)));

      tabHost.setCurrentTab(1);
      tabHost.setOnTabChangedListener(new OnTabChangeListener() {
  //        @Override
      public void onTabChanged(String arg0) {
        	  if (arg0.equals("tab3"))
        	  {
        		  tabHost.refreshDrawableState();
        	  }
      }

     });
    }
}

info.java

package com.powenko.Tutorial_UI_Tab;

import android.app.Activity;
import android.os.Bundle;

public class info extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

}

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.powenko.Tutorial_UI_Tab"

android:versionCode="1"

android:versionName="1.0">

<uses-sdk android:minSdkVersion="4" />

&nbsp;

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".Tutorial_UI_TabActivity"

android:label="@string/app_name">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<activity android:name="info" ></activity>

</application>

</manifest>

sample code:

please download from here, “Tutorial_UI_TabActivity” ,

http://code.google.com/p/powenko-android-tutorial/

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon