2010-12-30 9 views
0

私は現在、4つのタブを持つレイアウトを持っています。最初のタブには、アプリのホーム画面があり、他のアクティビティのアイコンに対して4つの画像ビューが読み込まれます。 2番目のタブは、3番目のタブと同様にwebview(非常に基本的なもの)を読み込みます。最後のタブはマップをロードします。アプリケーションのロードが非常に遅く、約11秒かかってしまい、Eclipseでデバッグするとき、ほとんどの時間がsetContentViewに費やされますが、レイアウトに何がかかるか分かりません。レイアウトロード時間をより効率的にするにはどうすればよいですか?

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

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      > 
      <RelativeLayout 
       android:id="@+id/tab1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/background" 
       > 
       <ImageView 
        android:id="@+id/HomeButtonEvents" 
        android:src="@drawable/eventsicon" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:paddingBottom="95dp" 
        android:clickable="true" 
        /> 
       <ImageView 
        android:id="@+id/CancelledClasses" 
        android:src="@drawable/cancelledicon" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        /> 
       <ImageView 
        android:id="@+id/CourseSchedule" 
        android:src="@drawable/coursesicon" 
        android:layout_width="141dp" 
        android:layout_height="139dp" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        /> 
       <ImageView 
        android:id="@+id/POTD" 
        android:src="@drawable/potdicon" 
        android:layout_width="294dp" 
        android:layout_height="247dp" 
        android:paddingTop="45dp" 
        android:paddingRight="1dp" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentRight="true" 
        android:layout_toRightOf="@id/CourseSchedule" 
        /> 
<!--   <ImageView --> 
<!--    android:id="@+id/potdview"--> 
<!--    android:layout_width="wrap_content"--> 
<!--    android:layout_height="wrap_content"--> 
<!--    android:paddingTop="0dp" --> 
<!--    android:paddingRight="1dp"--> 
<!--    android:paddingBottom="150dp" --> 
<!--    android:layout_alignParentTop="true"--> 
<!--    android:layout_alignParentRight="true" --> 
<!--    android:layout_toRightOf="@id/CourseSchedule" --> 
<!--    /> --> 
      </RelativeLayout> 

      <WebView 
       android:id="@+id/tab2" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       /> 

     </FrameLayout> 

     <TabWidget 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      /> 

    </LinearLayout> 

</TabHost> 

任意のアイデア/提案:ここ

私のレイアウトのコードはありますか?

+0

私はあなたのコードを読みやすくするためにフォーマットしました。私はこれがあなたの問題だとは知らないが、XMLタグ内にコメント行( '')を置くことはできない。そのブロックをコメントアウトするには '<! - - > 'で閉じるだけです。 – kcoppock

+0

問題に影響していなかった書式設定のヒントをいただきありがとうございました。Eclipseでトグルコメント機能を使用していたばかりです。 – Brandon

答えて

0

あなたがタブとして絶対に持っていなければ、4つのタブを別々のアクティビティに分割することをお勧めします。それらをタブとして使用する場合は、タブがフォーカスされているときに、タブのコンテンツを動的に読み込むことができます。

0

レイアウトオブジェクトが多すぎるようです。私はあなたがTabHostとRelativeLayoutだけですべてを行うことができるはずだと信じています。

+0

私はあなたの提案に従い、LinearLayoutを削除しようとしましたが、ロード時間から2〜3秒短縮しました。ただし、タブウィジェットは下部の代わりに上部に配置され、残りのビューは画面全体を塗りつぶすので、タブウィジェットはビューの一部をブロックします。私が読んだことから、LinearLayoutとFrameLayoutは必要ありませんか?私はビューで作業するためにすべてを得るために削除することができる他のどの部分がわからない... – Brandon

+0

訂正:LinearLayoutは実際には時間を節約できませんでした。 – Brandon

関連する問題