English 中文(简体)
无休止的阿普兰问题
原标题:EndlessAdapter issue

我试图采用无休止的适应器。 一项活动——说是一种口头行为,它提供了扩展活动的抽象类别。 在一些例子中,我看到,活动从清单活动延伸――是关键吗? 我还有一份清单改编者,提供基调适应器,而ArrayAdapter则使用。 当我到名单上结束时,我有了一个错误(下文表2)。

Would you mind point what the problem might be and whether there re uncertainties in this way of implementing of Endless ? Additionaly I would appreciate links on thorough examples. I ve seen demo - but it s not enough clear for me. Thanks.

My activity

public class ClipsActivity extends AbstractActivity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        try {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.clips);

            _init();
            ListView clipList = (ListView) findViewById(R.id.clipList);
            EndlessClipListAdapter endlessClipsList = new EndlessClipListAdapter(getApplicationContext(), new ClipListAdapter(this, _getClips()), R.id.downloadBar);
            clipList.setAdapter(endlessClipsList);
        } catch (HTTPFactoryException e) {
            e.printStackTrace();
        }
    }

我的无休止者

public class EndlessClipListAdapter extends EndlessAdapter {

    private RotateAnimation rotate=null;

    public EndlessClipListAdapter(Context context, ListAdapter wrapped, int pendingResource) {
        super(context, wrapped, pendingResource);
        rotate=new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotate.setDuration(600);
        rotate.setRepeatMode(Animation.RESTART);
        rotate.setRepeatCount(Animation.INFINITE);
    }

    @Override
    protected boolean cacheInBackground() throws Exception {
        SystemClock.sleep(10000);
        return(getWrappedAdapter().getCount()<14);
    }

    @Override
    protected void appendCachedData() {
        if (getWrappedAdapter().getCount()<14) {
        }
    }

    @Override
    protected View getPendingView(ViewGroup parent) {
        //View row=getLayoutInflater().inflate(R.layout.row, null);
        //LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

        LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );

        View row = inflater.inflate(R.layout.row, null);
        View child=row.findViewById(android.R.id.text1);

        child.setVisibility(View.GONE);

        child=row.findViewById(R.id.throbber);
        child.setVisibility(View.VISIBLE);
        child.startAnimation(rotate);

        return(row);
      }

}

后勤

04-20 13:41:43.083: W/dalvikvm(480): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-20 13:41:43.093: E/AndroidRuntime(480): FATAL EXCEPTION: main
04-20 13:41:43.093: E/AndroidRuntime(480): java.lang.IndexOutOfBoundsException: Invalid index 15, size is 15
04-20 13:41:43.093: E/AndroidRuntime(480):  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
04-20 13:41:43.093: E/AndroidRuntime(480):  at java.util.ArrayList.get(ArrayList.java:311)
04-20 13:41:43.093: E/AndroidRuntime(480):  at ru.localhost.xxxx.android.view.ClipListAdapter.getItemId(ClipListAdapter.java:47)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.commonsware.cwac.adapter.AdapterWrapper.getItemId(AdapterWrapper.java:127)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.AdapterView.getItemIdAtPosition(AdapterView.java:745)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.AdapterView.setSelectedPositionInt(AdapterView.java:1088)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.ListView.arrowScrollImpl(ListView.java:2324)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.ListView.arrowScroll(ListView.java:2287)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.ListView.commonKey(ListView.java:2089)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.ListView.onKeyDown(ListView.java:2036)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.KeyEvent.dispatch(KeyEvent.java:1256)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.View.dispatchKeyEvent(View.java:3855)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:787)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.widget.ListView.dispatchKeyEvent(ListView.java:2021)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1687)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1120)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.app.Activity.dispatchKeyEvent(Activity.java:2073)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1663)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.os.Looper.loop(Looper.java:123)
04-20 13:41:43.093: E/AndroidRuntime(480):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-20 13:41:43.093: E/AndroidRuntime(480):  at java.lang.reflect.Method.invokeNative(Native Method)
04-20 13:41:43.093: E/AndroidRuntime(480):  at java.lang.reflect.Method.invoke(Method.java:507)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-20 13:41:43.093: E/AndroidRuntime(480):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-20 13:41:43.093: E/AndroidRuntime(480):  at dalvik.system.NativeStart.main(Native Method)
问题回答

在一些例子中,我看到,活动从清单活动延伸――是关键吗?

页: 1 欢迎您使用<代码>ListFragment,或使用<代码>ListView的便衣活动。

我还有一份清单改编者,提供基调适应器,而ArrayAdapter则使用。

适应者需要支持估算额外数据的概念。 <代码>ArrayAdapter;CursorAdapter。 我不能说您的适应者是否愿意或不会。

你们会想到问题是什么。

I do not know for certain. The fact that your appendCachedData() is not actually appending anything would be a likely candidate. Please read the documentation and follow its instructions.

此外,我还要感谢有关详尽例子的联系。

in the repo

I ve seen demo - but it s not enough clear for me.

其他地方也有这种模式的其他实施;或许这些组成部分之一更适合你们。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签