0
E/Surface(11901): Surface (identity=16464) requestBuffer(1, 0, 0, 0, 00000033) 
    returned a buffer with a null handle
E/Surface(11901): getBufferLocked(1, 0, 0, 0, 00000033) failed (Out of memory)
E/Surface(11901): dequeueBuffer failed (Out of memory)
E/ViewRoot(11901): OutOfResourcesException locking surface
E/ViewRoot(11901): android.view.Surface$OutOfResourcesException
E/ViewRoot(11901):  at android.view.Surface.lockCanvasNative(Native Method)
E/ViewRoot(11901):  at android.view.Surface.lockCanvas(Surface.java:314)
E/ViewRoot(11901):  at android.view.ViewRoot.draw(ViewRoot.java:1467)
E/ViewRoot(11901):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
E/ViewRoot(11901):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1873)
E/ViewRoot(11901):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/ViewRoot(11901):  at android.os.Looper.loop(Looper.java:130)
E/ViewRoot(11901):  at android.app.ActivityThread.main(ActivityThread.java:3703)
E/ViewRoot(11901):  at java.lang.reflect.Method.invokeNative(Native Method)
E/ViewRoot(11901):  at java.lang.reflect.Method.invoke(Method.java:507)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
    .run(ZygoteInit.java:841)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/ViewRoot(11901):  at dalvik.system.NativeStart.main(Native Method)

E/Surface(11901): Surface (identity=16461) requestBuffer(1, 0, 0, 0, 00000033) 
    returned a buffer with a null handle
E/Surface(11901): getBufferLocked(1, 0, 0, 0, 00000033) failed (Out of memory)
E/Surface(11901): dequeueBuffer failed (Out of memory)
E/ViewRoot(11901): OutOfResourcesException locking surface
E/ViewRoot(11901): android.view.Surface$OutOfResourcesException
E/ViewRoot(11901):  at android.view.Surface.lockCanvasNative(Native Method)
E/ViewRoot(11901):  at android.view.Surface.lockCanvas(Surface.java:314)
E/ViewRoot(11901):  at android.view.ViewRoot.draw(ViewRoot.java:1467)
E/ViewRoot(11901):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
E/ViewRoot(11901):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1873)
E/ViewRoot(11901):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/ViewRoot(11901):  at android.os.Looper.loop(Looper.java:130)
E/ViewRoot(11901):  at android.app.ActivityThread.main(ActivityThread.java:3703)
E/ViewRoot(11901):  at java.lang.reflect.Method.invokeNative(Native Method)
E/ViewRoot(11901):  at java.lang.reflect.Method.invoke(Method.java:507)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
    .run(ZygoteInit.java:841)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/ViewRoot(11901):  at dalvik.system.NativeStart.main(Native Method)

E/Surface(11901): Surface (identity=16462) requestBuffer(1, 0, 0, 0, 00000033) 
    returned a buffer with a null handle
E/Surface(11901): getBufferLocked(1, 0, 0, 0, 00000033) failed (Out of memory)
E/Surface(11901): dequeueBuffer failed (Out of memory)
E/ViewRoot(11901): OutOfResourcesException locking surface
E/ViewRoot(11901): android.view.Surface$OutOfResourcesException
E/ViewRoot(11901):  at android.view.Surface.lockCanvasNative(Native Method)
E/ViewRoot(11901):  at android.view.Surface.lockCanvas(Surface.java:314)
E/ViewRoot(11901):  at android.view.ViewRoot.draw(ViewRoot.java:1467)
E/ViewRoot(11901):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
E/ViewRoot(11901):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1873)
E/ViewRoot(11901):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/ViewRoot(11901):  at android.os.Looper.loop(Looper.java:130)
E/ViewRoot(11901):  at android.app.ActivityThread.main(ActivityThread.java:3703)
E/ViewRoot(11901):  at java.lang.reflect.Method.invokeNative(Native Method)
E/ViewRoot(11901):  at java.lang.reflect.Method.invoke(Method.java:507)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
    .run(ZygoteInit.java:841)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/ViewRoot(11901):  at dalvik.system.NativeStart.main(Native Method)

E/Surface(11901): Surface (identity=16463) requestBuffer(1, 0, 0, 0, 00000033) 
    returned a buffer with a null handle
E/Surface(11901): getBufferLocked(1, 0, 0, 0, 00000033) failed (Out of memory)
E/Surface(11901): dequeueBuffer failed (Out of memory)
E/ViewRoot(11901): OutOfResourcesException locking surface
E/ViewRoot(11901): android.view.Surface$OutOfResourcesException
E/ViewRoot(11901):  at android.view.Surface.lockCanvasNative(Native Method)
E/ViewRoot(11901):  at android.view.Surface.lockCanvas(Surface.java:314)
E/ViewRoot(11901):  at android.view.ViewRoot.draw(ViewRoot.java:1467)
E/ViewRoot(11901):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
E/ViewRoot(11901):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1873)
E/ViewRoot(11901):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/ViewRoot(11901):  at android.os.Looper.loop(Looper.java:130)
E/ViewRoot(11901):  at android.app.ActivityThread.main(ActivityThread.java:3703)
E/ViewRoot(11901):  at java.lang.reflect.Method.invokeNative(Native Method)
E/ViewRoot(11901):  at java.lang.reflect.Method.invoke(Method.java:507)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
    .run(ZygoteInit.java:841)
E/ViewRoot(11901):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/ViewRoot(11901):  at dalvik.system.NativeStart.main(Native Method)

ViewPagerFragment.java

package nsixty.crew.app;

import java.util.List;
import java.util.Vector;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.viewpagerindicator.TitlePageIndicator;
import com.viewpagerindicator.TitleProvider;

public class ViewPagerFragment extends FragmentActivity {

    private CustomFragmentAdapter mPagerAdapter;

    ViewPager pager;
    TitlePageIndicator titleIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.viewpager);

        this.initialisePaging();

    }

    private void initialisePaging() {

        List<Fragment> fragments = new Vector<Fragment>();

        fragments
                .add(Fragment.instantiate(this, LoginActivity.class.getName()));
        fragments.add(Fragment.instantiate(this, main.class.getName()));
        this.mPagerAdapter = new CustomFragmentAdapter(
                super.getSupportFragmentManager(), fragments);
        pager = (ViewPager) findViewById(R.id.viewpager);
        pager.setAdapter(this.mPagerAdapter);
//        titleIndicator = (TitlePageIndicator) findViewById(R.id.);
//        titleIndicator.setViewPager(pager);
    }

    public static class CustomFragmentAdapter extends FragmentPagerAdapter
            implements TitleProvider {
        public static final int POSITION_PAGE_1 = 0;
        public static final int POSITION_PAGE_2 = 1;
        public static final int POSITION_PAGE_3 = 2;
        private List<Fragment> fragments;
        private static final String[] TITLES = new String[] { "LOGIN", "HOME" };
        public static final int NUM_TITLES = TITLES.length;

        @Override
        public String getTitle(int position) {
            return TITLES[position];
        }

        public CustomFragmentAdapter(FragmentManager fm,
                List<Fragment> fragments) {
            super(fm);
            this.fragments = fragments;
        }

        @Override
        public int getCount() {
            // return this.fragments.size();
            return NUM_TITLES;
        }

        @Override
        public Fragment getItem(int position) {

            try {
                LoginActivity.class.newInstance();
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return this.fragments.get(position);
        }
    }
}

类似问题

链接 1 ,链接 2

帮助,我需要帮助不知道这些是什么错误我已经研究过,我没有看到任何合理的答案......这很奇怪,我不知道这些是什么错误。我只是在做一个只有两张幻灯片的简单视图寻呼机。

4

1 回答 1

1

我从我的main.java. 我有菜单类(在选项创建)一半评论留下选项创建类和 xml 值在错误的 xml 文件中。对于那些面临这种问题的人,这是我为诊断这个问题所做的:

  • 我创建了两个只有一个按钮属性的空类(轻量级片段)。
  • 然后我测试它是否有效。
  • 然后我尝试了我正在使用的每个片段中的一个(即登录活动和主要活动)......就像这样LoginActivity,样本 1 片段工作。
  • 然后我尝试了 main 和 sample 1 或 2,但我发现它不起作用,问题出在 main 上,所以我跟踪它并发现它是什么。

我希望这会有所帮助..
无论如何,我使用这个View pager extensions来完善我的项目。

于 2012-10-13T16:58:55.997 回答