0

I got Height 0, which is printing in log cat.

On MainJava file:

RealViewSwitcher realViewSwitcher = (RealViewSwitcher) findViewById(R.id.horizontal_pager);
        realViewSwitcher.setOnScreenSwitchListener(onScreenSwitchListener);

RealViewSwitcher.java file where this include: @Override

protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

final int width = MeasureSpec.getSize(widthMeasureSpec);
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
if (widthMode != MeasureSpec.EXACTLY) {
    Log.d("TAG", "First MeastueSpece.Exactly Out Put:"+MeasureSpec.EXACTLY);
    Log.d("TAG", "First Width Out Put:"+widthMode);
    throw new IllegalStateException("ViewSwitcher can only be used in EXACTLY mode. at Width Mode");
}

final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (heightMode != MeasureSpec.EXACTLY) {

    Log.d("TAG", "First MeastueSpece.Exactly  Out Put:"+MeasureSpec.EXACTLY);
    Log.d("TAG", "First heightModeOut Put:"+heightMode);
    throw new IllegalStateException("ViewSwitcher can only be used in EXACTLY mode. at Height Mode");
}
......

In Layout file:

<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="45dp"
        android:layout_marginTop="54dp" >

        <com.test.RealViewSwitcher
            android:id="@+id/horizontal_pager"
            android:layout_width="fill_parent"
            android:layout_height="0px"
            android:orientation="vertical" 
            android:layout_weight="1" >
        </com.test.RealViewSwitcher>
    </ScrollView>

I got this in Logcat:

06-20 09:42:55.952: D/TAG(1329): First heightMode Out Put:0
06-20 09:42:55.962: D/TAG(1329): First MeastueSpece.Exactly Out Put:1073741824
06-20 09:42:55.962: W/Trace(1329): Unexpected value from nativeGetEnabledTags: 0
06-20 09:42:55.972: W/Trace(1329): Unexpected value from nativeGetEnabledTags: 0
06-20 09:42:55.972: D/AndroidRuntime(1329): Shutting down VM
06-20 09:42:55.984: W/dalvikvm(1329): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
06-20 09:42:56.253: E/AndroidRuntime(1329): FATAL EXCEPTION: main
06-20 09:42:56.253: E/AndroidRuntime(1329): java.lang.IllegalStateException: ViewSwitcher can only be used in EXACTLY mode. at Height Mode

1 Answers1

0

Just hard code the height. Replace with this,

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="45dp"
    android:layout_marginTop="54dp" >

    <com.test.RealViewSwitcher
        android:id="@+id/horizontal_pager"
        android:layout_width="fill_parent"
        android:layout_height="550dp"
        android:orientation="vertical" 
        android:layout_weight="1" >
    </com.test.RealViewSwitcher>
</ScrollView>
Exceptional
  • 2,994
  • 1
  • 18
  • 25