在android系统上ViewFlipper工作 [英] Working on ViewFlipper in android

查看:185
本文介绍了在android系统上ViewFlipper工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我现在用的是下面的code与描述一起翻转图像。

Hi I am using the following code for flipping the images along with the description.

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

    <ViewFlipper
        android:id="@+id/view_flipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/lightning" />

            <TextView
                style="@style/ImageTitle"
                android:text="@string/lightning" />
        </RelativeLayout>

       <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

         <ImageView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/color_baloons" />

            <TextView
                style="@style/ImageTitle"
                android:text="@string/color_baloons" />
        </RelativeLayout> 

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/natural_wall" />

            <TextView`enter code here`
                style="@style/ImageTitle"
                android:text="@string/natural_wall" />
        </RelativeLayout>
   </ViewFlipper>
</RelativeLayout>

如果我运行上面的code中的应用程序崩溃。但是,如果我从第二的RelativeLayout删除的ImageView的code是工作的罚款。我粘贴的logcat也在这里。

If I run the above code the app is crashing. But if I remove the ImageView from the second RelativeLayout the code is working fine. I am pasting the logcat also here.

    04-02 01:58:54.683: E/AndroidRuntime(1166): FATAL EXCEPTION: main
    04-02 01:58:54.683: E/AndroidRuntime(1166): java.lang.RuntimeException: Unable to start             activityComponentInfo{com.javatechig.viewflipper/com.javatechig.viewflipper.ViewFlipperSampleActivity}: android.view.InflateException: Binary XML file line #34: Error inflating class <unknown>
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.os.Handler.dispatchMessage(Handler.java:99)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.os.Looper.loop(Looper.java:137)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at android.app.ActivityThread.main(ActivityThread.java:5103)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at java.lang.reflect.Method.invoke(Method.java:525)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    04-02 01:58:54.683: E/AndroidRuntime(1166):     at dalvik.system.NativeStart.main(Native Method)
    04-02 01:58:54.683: E/AndroidRuntime(1166): Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class <unknown>

在同一code为工作的设备类型3.7和运行时INT 5.4它不工作。中的minSdkVersion是18。

The same code is working for device type 3.7 and when run int 5.4 it is not working. The minSdkVersion is 18.

感谢您

推荐答案

我不得不增加VM堆在创建模拟器。这是在默认情况下16和我试着用64和它的工作。

I had to increase the VM heap while creating the emulator. It was by default 16 and I tried with 64 and it worked.

这篇关于在android系统上ViewFlipper工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆