1

나는 검색을하고 내가 물어볼 것 같았던 문제에 가까운 것을 찾을 수 있었다. 나는 enter image description hereTabHost로 안드로이드 대시 보드 레이아웃

모두가 Tabhost 정의 아래 그림과 같이 (내가 한 일이

제대로 할 원하는 것은 노력하고 대시 보드 레이아웃을 가지고 있지만 나는 설정 클래스에로했다 액션 바 탐색을 중단 TabActivity)를 확장

enter image description here

탭이 올바르게 전환하지만이 날의 버튼 중 하나를 사용하도록 허용하지 않습니다 작업 표시 줄, 그 당겨없는 정보가 제대로처럼 제대로

enter image description here

위의 작품이어야한다. 그래서 내 질문에 내 클래스에 TabHost를 올바르게 추가하고 대시 보드 코드를 확장 또는 구현할 수 있습니까? 나는 TabActivity가 운이없는 대시 보드를 구현하는 확장을 시도했다. 여기

는 Dashboard.java

package com.ondrovic.bbym; 

import android.app.Activity; 
import android.content.Context; 
import android.content.Intent; 
import android.content.res.Configuration; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.LinearLayout; 
import android.widget.TextView; 

public abstract class Dashboard extends Activity { 
public static final boolean usePrettyGoodSolution = false; 

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
} 

public void onDestroy() { 
    super.onDestroy(); 
} 

public void onPause() { 
    super.onPause(); 
} 

public void onRestart() { 
    super.onRestart(); 
} 

public void onResume() { 
    super.onResume(); 
} 

public void onStart() { 
    super.onStart(); 
} 

public void onStop() { 
    super.onStop(); 
} 

public void onClickHome(View v) { 
    goHome(this); 
} 

public void onClickUpdate(View v) { 
    //startActivity(new Intent(getApplicationContext(), Update.class)); 
} 

public void onClickAbout(View v) { 
    //startActivity(new Intent(getApplicationContext(), About.class)); 
} 

public void goHome(Context context) { 
    final Intent intent = new Intent(context, Home.class); 
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    context.startActivity(intent); 
} 

@Override 
public void setContentView(int layoutID) { 
    if (!usePrettyGoodSolution) { 
     super.setContentView(layoutID); 
     return; 
    } 

    Configuration c = getResources().getConfiguration(); 
    int size = c.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; 
    boolean isLarge = (size == Configuration.SCREENLAYOUT_SIZE_LARGE); 
    boolean isXLarge = (size == Configuration.SCREENLAYOUT_SIZE_XLARGE); 
    boolean addFrame = isLarge || isXLarge; 

    // if (isLarge) System.out.println ("Large screen"); 
    // if (isXLarge) System.out.println ("XLarge screen"); 

    int finalLayoutId = addFrame ? R.layout.large : layoutID; 
    super.setContentView(finalLayoutId); 

    if (addFrame) { 
     LinearLayout frameView = (LinearLayout) findViewById(R.id.frame); 
     if (frameView != null) { 

      // If the frameView is there, inflate the layout given as an 
      // argument. 
      // Attach it as a child to the frameView. 
      LayoutInflater li = ((Activity) this).getLayoutInflater(); 
      View childView = li.inflate(layoutID, null); 
      if (childView != null) { 
       LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
         ViewGroup.LayoutParams.MATCH_PARENT, 
         ViewGroup.LayoutParams.MATCH_PARENT, 1.0F); 
       frameView.addView(childView, lp); 
       // childView.setBackgroundResource (R.color.background1); 
      } 

     } 
    } 
} 

public void setTitleFromActivityLabel(int textViewID) { 
    TextView tv = (TextView) findViewById(textViewID); 
    if (tv !=null) { 
     tv.setText(getTitle()); 
    } 
} 

} 

Individual.java 지금까지

내 코드가있는 경우 여기에

package com.ondrovic.bbym; 

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

public class Individual extends TabActivity { 
public void onCreate(Bundle savedSate) { 
    super.onCreate(savedSate); 
    setContentView(R.layout.individual); 

    TabHost tabHost = getTabHost(); 
    TabSpec attspec = tabHost.newTabSpec("ATT"); 
    attspec.setIndicator("AT&T", getResources().getDrawable(R.drawable.icons_att_tab)); 
    Intent attIntent = new Intent(this, Individual_ATT.class); 
    attspec.setContent(attIntent); 

    TabSpec sprspec = tabHost.newTabSpec("SPRINT"); 
    sprspec.setIndicator("SPRINT", getResources().getDrawable(R.drawable.icons_sprint_tab)); 
    Intent sprIntent = new Intent(this, Individual_SPRINT.class); 
    sprspec.setContent(sprIntent); 

    TabSpec vzwspec = tabHost.newTabSpec("VERIZON"); 
    vzwspec.setIndicator("VERIZON", getResources().getDrawable(R.drawable.icons_verizon_tab)); 
    Intent vzwIntent = new Intent(this, Individual_VERIZON.class); 
    vzwspec.setContent(vzwIntent); 

    tabHost.addTab(attspec); 

    tabHost.addTab(sprspec); 

    tabHost.addTab(vzwspec); 
} 
} 

내 individual.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/background1" 
android:orientation="vertical" > 

<include layout="@layout/title_bar" /> 
<include layout="@layout/tabs" /> 
</LinearLayout> 

입니다 다른 코드 t 모자가 게시물이되어야합니다 알려 주시기 바랍니다 도움을 주셔서 감사합니다

+0

노력의 한 내용입니다 Android에서 탭을 사용하기 위해 TabActivity를 확장 할 필요가 없습니다. 그들이 당신이 원하는 것과 비슷한 것을하는 곳이라면 어둡게 처리 된 앱 소스 코드를 살펴보십시오. – Cristian

+0

나는 iosched를 보았다. 그러나 나의 수준 위에 그것의 조금 조금 조금은 지금 정보 그러나 감사합니다. – ondrovic

답변

0

그래서 나는 다음을 수행하여 그것을 알아 냈어. 심지어 여기에 더 나은 방법 아마이 있지만 것은 내가

Individual.java 여기

package com.ondrovic.bbym; 

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

public class Individual extends Dashboard { 
    TabHost mTabs; 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.individual); 
    setTitleFromActivityLabel(R.id.title_text); 

    mTabs = (TabHost) findViewById(android.R.id.tabhost); 
    LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false); 
    mLocalActivityManager.dispatchCreate(savedInstanceState); 
    mTabs.setup(mLocalActivityManager); 

    TabSpec attspec = mTabs.newTabSpec("ATT"); 
    attspec.setIndicator("AT&T", getResources().getDrawable(R.drawable.icons_att_tab)); 
    Intent attIntent = new Intent(this, Individual_ATT.class); 
    attspec.setContent(attIntent); 

    TabSpec sprintspec = mTabs.newTabSpec("SPRINT"); 
    sprintspec.setIndicator("SPRINT", getResources().getDrawable(R.drawable.icons_sprint_tab)); 
    Intent sprintIntent = new Intent(this, Individual_SPRINT.class); 
    sprintspec.setContent(sprintIntent); 

    TabSpec verizonspec = mTabs.newTabSpec("VERIZON"); 
    verizonspec.setIndicator("VERIZON", getResources().getDrawable(R.drawable.icons_verizon_tab)); 
    Intent verizonIntent = new Intent(this, Individual_ATT.class); 
    verizonspec.setContent(verizonIntent); 

    mTabs.addTab(attspec); 
    mTabs.addTab(sprintspec); 
    mTabs.addTab(verizonspec); 
} 
} 

을받은 결과 모든 명심 :-)

enter image description here