Giter VIP home page Giter VIP logo

Comments (10)

kaleai avatar kaleai commented on June 10, 2024

bindview是不会加载多次的,你可以试试你放入100条数据,你就放一个item,然后看看log的数目是多少,可以尝试一下,如果仍旧是100次,那么就是我的严重失误了。咱们可以一起来看看

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

我稍微所以下我是怎么用的:

AdapterItem:

@Override
public int getLayoutResId() {
    return R.layout.item_note;
}

@Override
public void bindViews(View view) {
    KLog.w();//打Log
    x.view().inject(this, view);//注入
}

@Override
public void handleData(Note note, int i) {
    tv_title.setText(note.getName());
}

Fragment:

private CommonAdapter<Note> noteAdapter = new CommonAdapter<Note>(null, 1) {
    @NonNull
    @Override
    public AdapterItem createItem(Object o) {
        return new NoteItem();
    }
};

......

//加载到数据
mListView.setAdapter(noteAdapter);
noteAdapter.setData(taskNotes);
noteAdapter.notifyDataSetChanged();

from commonadapter.

kaleai avatar kaleai commented on June 10, 2024

嗯,好。然后看log

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

04-08 10:10:36.008 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.018 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.038 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.058 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.078 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.088 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

总共有6条数据,bindVIews执行了6次

from commonadapter.

kaleai avatar kaleai commented on June 10, 2024

你放100条。

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

好吧,意思是说这个bindViews会执行屏幕允许的item数量的次数吗?

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

那这样的话,也会有一定性能上的影响吧,比如一个页面有十几个item的(不知道gridview会不会这样)

from commonadapter.

kaleai avatar kaleai commented on June 10, 2024

是的,这个是listview本身的复用逻辑。这个和性能无关,这是必须的。我给你发一个我写的简单介绍,你看看就明白了:http://www.cnblogs.com/tianzhijiexian/p/4769959.html

from commonadapter.

Andecy avatar Andecy commented on June 10, 2024

恍然大悟,非常感谢耐心解答!

from commonadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.