本文介绍了什么时候Android的ListActivity类调用的setContentView()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图使用 requestWindowFeature()函数来设置一个列表活动自定义标题视图。该方法正常工作与一种观点认为,只有子类活动,但每当我试图用 ListActivity 子类相同的方法,它的错误,给我一个NullPointerException异常,当我尝试以编程方式修改标题视图。

I'm trying to use the requestWindowFeature() function to set a custom title view on a list activity. The method works fine with a view that only subclasses Activity, but whenever I try the same method with a ListActivity subclass, it errors, giving me a NullPointerException when I try to programmatically modify the title view.

我认为这个问题涉及到 requestWindowFeature()之前需要的setContentView被称为事实()。因为 ListActivity 负责设置内容视图为你,我不知道被调用时。有没有人有什么建议?感谢您的帮助。

I believe the problem pertains to the fact that requestWindowFeature() needs to be called before setContentView(). Because ListActivity takes care of setting the content view for you, I don't know when that is being called. Does anyone have any suggestions? Thanks for the help.

推荐答案

当你与List交互,例如调用的GetList()或listactivity setAdapter()的setContentView被调用。请参阅<一个href=\"http://www.grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.3.4_r1/android/app/ListActivity.java#ListActivity\"相对=nofollow> listactivity源

setContentView is called whenever you interact with the List, for example calling getList() or setAdapter() on listactivity. See the source of listactivity

这篇关于什么时候Android的ListActivity类调用的setContentView()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 08:54