멜론앱을 보면 상단의 텝을 눌러서 액티비티를 변경해도 하단에 플레이어부분은 그대로 남아있습니다.
public class gstab extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ) ; //setContentView( R.layout.main ) ; TabHost tabHost = getTabHost( ) ; tabHost.addTab( tabHost.newTabSpec( "tab1" ) .setIndicator( "ONE" ) .setContent( new Intent( this, tab1.class ) ) ) ; tabHost.addTab( tabHost.newTabSpec( "tab2" ) .setIndicator( "TWO" ) .setContent( new Intent( this, tab2.class ) ) ) ; tabHost.addTab( tabHost.newTabSpec( "tab3" ) .setIndicator( "THREE" ) .setContent( new Intent( this, tab3.class ) ) ) ; tabHost.setCurrentTab( 0 ) ; } }
위와같이 TabActivity를 상속받아서 메뉴를 만들었다고 가정했을때
탭을 누르면 새 액티비티가 화면을 차지하는데
하단의 플레이어부분을 만들고 탭이 바뀌어서 새 액티비티로 교체되어도
플레이어 부분만은 그대로 두고 싶습니다.
질문을 처음 올리는데 공지사항은 읽어 보았습니다.

킈킈

책에있는 예제를 활용하여 다음과 같이 해결 하였습니다.
[main.xml]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton android:id="@+id/ImageButton09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/miniplayer_bottombtn"
android:layout_alignParentBottom="true"></ImageButton>
</RelativeLayout>
[gstab.java]
package com.gstab;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
public class gstab extends TabActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate( savedInstanceState ) ;
//setContentView( R.layout.main ) ;
TabHost tabHost = getTabHost( ) ;
LayoutInflater.from( this ).inflate( R.layout.main, tabHost.getTabContentView( ), true ) ;
tabHost.addTab( tabHost.newTabSpec( "tab1" )
.setIndicator( "ONE" )
.setContent( new Intent( this, tab1.class ) ) ) ;
tabHost.addTab( tabHost.newTabSpec( "tab2" )
.setIndicator( "TWO" )
.setContent( new Intent( this, tab2.class ) ) ) ;
tabHost.addTab( tabHost.newTabSpec( "tab3" )
.setIndicator( "THREE" )
.setContent( new Intent( this, tab3.class ) ) ) ;
tabHost.addTab( tabHost.newTabSpec( "tab4" )
.setIndicator( "FOUR" )
.setContent( new Intent( this, tab4.class ) ) ) ;
tabHost.addTab( tabHost.newTabSpec( "tab5" )
.setIndicator( "FIVE" )
.setContent( new Intent( this, tab5.class ) ) ) ;
tabHost.setOnTabChangedListener( new OnTabChangeListener( )
{
@Override
public void onTabChanged(String tabId)
{
if( tabId == "tab1" )
{
findViewById( R.id.ImageButton09 ).setVisibility( 4 ) ;
}
else
{
findViewById( R.id.ImageButton09 ).setVisibility( 0 ) ;
}
// TODO Auto-generated method stub
}
} ) ;
tabHost.setCurrentTab( 0 ) ;
findViewById( R.id.ImageButton09 ).setVisibility( 4 ) ;
}
}
위와같이 구성하면 다른 액티비티가 앞에 오더라도 main.xml에 구성한 내용은 유지가 되더군요
답글 달아주신 방법도 해보겠습니다.
감사합니다.
안드로이드 2.1
참고한 책 : 예제로 시작하는 안드로이드 개발, 출판사 에이콘
안드로이드펍에서 옮김 이라고 되어있네요 ;;