2013-02-28 108 views
3

所以基本上,我有一個應用程序,它可以在我提供的所有設備和模擬器上運行。但有一些人報告沒有背景圖像,這使得文本無法閱讀。請幫忙,我不知道應用程序出錯的地方。來自FragmentActivity的片段不會在少數設備上顯示背景圖像

這裏是我的FragmentActivity文件(基本部分)

public class MainActivity extends FragmentActivity{ 

    private FragmentTabHost mTabHost; 

    @Override 

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

     setContentView(R.layout.activity_main); 


     Bundle b1 = new Bundle(); 
     b1.putInt("tabId",111); 

     Bundle b2 = new Bundle(); 
     b2.putInt("tabId",222); 


     final FragmentManager fm = getSupportFragmentManager(); 

     mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost); 
     mTabHost.setup(this, fm, R.id.realtabcontent); 

     mTabHost.addTab(mTabHost.newTabSpec("main").setIndicator("MAIN"), TabContentFragment.class, b1); 
     mTabHost.addTab(mTabHost.newTabSpec("massReading").setIndicator("MASS READING"), TabContentFragment.class, b2);   

     TabWidget tw = mTabHost.getTabWidget(); //this tabwidget is generated after "addTab", the one from layout is not doing anything   
     tw.setVisibility(0x00000008); // = "GONE" 
    } 
} 

和 「activity_main」 佈局文件

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg"> *******//This is the background image I need to display******** 

    <LinearLayout 
     android:id="@+id/top" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     style="@style/padding" 
     android:gravity="center" 
     android:background="@android:color/transparent" 
     > 
     <Button 
      android:id="@+id/back" 
      style="@style/btn" 
      android:background="@drawable/back" 
      /> 
     <TextView 
      android:id="@+id/title" 
      android:layout_height="wrap_content" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:textStyle="bold" 
      style="@style/title" 
      android:gravity="center" 
      /> 
     <Button 
      android:id="@+id/down" 
      style="@style/btn" 
      android:background="@drawable/decrease"  
      android:layout_marginRight="15dp" 
      />          
     <Button 
      android:id="@+id/up" 
      style="@style/btn" 
      android:background="@drawable/increase"       
      /> 
    </LinearLayout> 

    <android.support.v4.app.FragmentTabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:paddingLeft="10dp" 
     android:paddingRight="10dp" 
     android:background="@android:color/transparent" 
     > 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      /> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      /> 

     <FrameLayout 
      android:id="@+id/realtabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      /> 

    </android.support.v4.app.FragmentTabHost> 

    <RadioGroup 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/rg" 
     > 
     <RadioButton 
      android:id="@+id/main" 
      style="@style/rb" 
      android:drawableTop="@drawable/reflection" 
      android:text="@string/rb_left" 
      /> 
     <RadioButton 
      android:id="@+id/mr" 
      style="@style/rb" 
      android:drawableTop="@drawable/readings" 
      android:text="@string/rb_right" 
      /> 
    </RadioGroup> 

</LinearLayout> 

和碎片文件,該文件僅2網頁視圖

public class TabContentFragment extends Fragment { 

    WebView wv; 

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     if (container == null) { 
      return null; 
     } 


     Bundle b = getArguments(); 
     int tabId = b.getInt("tabId"); 

     wv = (WebView)inflater.inflate(R.layout.tab_content, container, false); 

     wv.setId(tabId); 
     wv.setVerticalScrollBarEnabled(false); 
     wv.setBackgroundColor(0); 

     if(tabId==111) 
     { 

      String htmlString = "<html xmlns='http://www.w3.org/1999/xhtml'>stuff</html>";   
      wv.loadDataWithBaseURL("",htmlString, "text/html", "UTF-8", ""); 
     } 
     else 
     { 
      String htmlString = "<html xmlns='http://www.w3.org/1999/xhtml'>stuff</html>";   
      wv.loadDataWithBaseURL("",htmlString, "text/html", "UTF-8", ""); 
     } 

     return wv; 
    } 
} 
+0

這裏是谷歌Play商店鏈接到我的應用程序https://play.google.com/store/apps/details?id=xt3.lent2011,如果你想嘗試應用程序,你可以下載apk文件http://www.xt3.com/files/Xt3Lent2013.3.3.apk並安裝到您的設備上。謝謝 – user580763 2013-02-28 06:15:11

回答

1

檢查細節在抱怨沒有位圖顯示的設備上,查找虛擬機預算。如果設備沒有足夠的內存來容納位圖,則可以簡單地將位圖設置爲空(或不設置背景)。鑑於你的症狀,我會說這是問題。