1

If I declared a class static and it's content static would this mean that the contents of the class are no longer static?

Here's what happened, I used a ViewHolder in a Custom Adapter in Android.

When my code was like this:

static class ViewHolder {
     static TextView blah;
     //more widgets
}

The ListView had repetitive data and the rows were shuffled on scroll.

However, when I did this, no duplicates were created. Basically there was just ONE instance of each list item created and the items didn't shuffle on scroll.

static class ViewHolder {
     public TextView blah;
     //more widgets
}

Now, I know that public is the default access specifer and did not have to do anything with the change. Does a double static cancel each other out? Is it like a double negative is a positive?

4

2 回答 2

1

仅当类是内部类时,类上的 static 修饰符才有意义。静态内部类意味着内部类的实例可以独立存在而无需外部类的实例。

成员变量上的 static 修饰符意味着对于封闭类的所有实例,该变量只有一个副本。

因此,静态修饰符对类对成员变量的静态修饰符没有影响。

于 2013-07-07T04:22:06.243 回答
0

双静电会相互抵消吗?

不。

我不明白你对你观察到的症状的描述,所以恐怕我不能提供任何进一步的建议;)

于 2013-07-07T04:16:08.210 回答