0

我在 viewpager 中有几个片段,每次调用它们的 onViewCreated() 时,我都会设置适配器,除非它已经设置好了。

我检查这个

getListAdapter() == null ? setAdapter() : //Otherwise do nothing

这很好用。但是,当我有一个 GridView 而不是 ListView 并且我执行相同的操作时,适配器始终为空,因此每次创建片段时都需要设置它。为什么是这样?

mGridView.getAdapter() == null ? setAdapter() : //Otherwise do nothing
4

0 回答 0