package com.neodreamer.MyTab;
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.OnTabChangeListener;
public class MyTab extends TabActivity implements OnTabChangeListener
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
// 첫 번째 탭
spec = tabHost.newTabSpec( "Tab 01" );
spec.setIndicator( "Tab 01",
getResources().getDrawable( R.drawable.icon ) );
spec.setContent( R.id.TabView1 );
tabHost.addTab( spec );
// 두 번째 탭
spec = tabHost.newTabSpec( "Tab 02" );
spec.setIndicator( "Tab 02" );
spec.setContent( R.id.TabView2 );
tabHost.addTab( spec );
// 세 번째 탭
spec = tabHost.newTabSpec( "Tab 03" );
spec.setIndicator( "Tab 03" );
spec.setContent( R.id.TabView3 );
tabHost.addTab( spec );
tabHost.setCurrentTab( 0 );
// Tab Change 이벤트 리스너 등록
tabHost.setOnTabChangedListener( this );
}
@Override
public void onTabChanged(String tabId)
{
String strMsg;
strMsg = "onTabChanged : " + tabId;
Toast.makeText( this, strMsg, Toast.LENGTH_SHORT ).show();
}
}
<
Original Post : http://neodreamer-dev.tistory.com/438
No comments :
Post a Comment