2016-02-10 25 views
0

我测试和开发的Android API级别21.一个普通手机上的应用程序中的每个视图正在工作,他们事情应该,也没有问题。Android的 - 的观点是看不见的时候,他们不应该(旧设备)

然而,API 16切换到一个较旧的装置的情况下,片段的一些特定的视图只是不可见。当离开片段并返回到相同的片段时,它将显示。

因此,例如,我打开应用程序,并创建开始片段。图像按钮被加载和显示,应该出现在它们下面的文本保持隐藏状态。 < - 不知道为什么

留下片段和回到它后,在按钮上的文本真的出现。

这种情况与许多其他的片段,我不知道如何这实际上可以发生,它是不一致以及..

这是特定部分我谈到:

<LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:id="@+id/dashboard_shortcut_timetable" 
     android:paddingBottom="10dp" 
     android:layout_weight="0.3"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/dashboard_shortcut_1" 
       android:src="@drawable/ic_shortcut" 
       android:background="@color/bg_white" 
       android:layout_centerHorizontal="true"/> 
     </RelativeLayout> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/dashboard_shortcut_timetable" 
      android:id="@+id/dashboard_shortcut_textview_1" 
      android:gravity="center|bottom"/> 

基本表示它的外观:

enter image description here

我只是设置文本,基本的Android的东西..

TextView dashboardShortCutTextview1 = (TextView) view.findViewById(R.id.dashboard_shortcut_textview_1); 
dashboardShortCutTextview1.setText(title1); 

所以,这发生在其他视图,以及一些菜单项,我必须在后期设置不可见/可见,以实际使其工作。

我的问题是;为什么会发生这种情况,如何解决这个问题,它取决于设备还是API级别?

回答

0

对于任何人有同样的问题,我找到了解决我的问题;

显然,multidex不得不被启用,因为我用了很多方法/库。太糟糕了logcat没有给我任何迹象,这是发生,这是造成这个问题。

这个multidex是什么? Read here

如何启用multidex支持?

build.gradle

android { 
    ... 
    defaultConfig { 
     ... 
     multiDexEnabled true 
    } 
} 

dependencies { 
    ... 
    compile 'com.android.support:multidex:1.0.1' 
    ... 
} 

为了向后兼容在主应用程序中添加此:

@Override 
protected void attachBaseContext(Context base) 
{ 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
} 
相关问题