问题描述
我希望显示类似于Android操作系统WiFi的设置对网络的列表(例如的,在图像的底部区域)。
然而,这样的事情是不是速效,所以我已经创建了一个扩展preference一个新的类,并且我在onCreateView返回只是一个ListView的实例。
i wish to show a listView on a PreferenceActivity similar to what the android OS wifi-settings has for the list of networks (example here , on the bottom area of the image) .however , such a thing isn't availabe , so i've created a new class that extends Preference , and what i returned in the onCreateView is just a ListView instance .
它的工作,但在ListView大约有一个项目的大小不变,无论我做什么它的LayoutParams不管我做什么适配器。即使我设置适配器onCreateView里面,它具有完全相同的大小。
it worked , but the listView has a constant size of about a single item no matter what i do to its layoutParams and no matter what i do to the adapter . even if i set the adapter inside the onCreateView , it has the exact same size .
,不仅如此,而且在ListView不能滚动,即使它是清楚的是它具有在其内的多个项目。
not only that , but the listView cannot be scrolled , even though it is clear that it has multiple items within it .
我想,当然,要使用相同的文字大小的标准为所有的preferences的,给本机的感觉。
i would , of course, want to use the same text size standard as on all of the preferences , to give a native feeling.
谁能告诉我什么可以为了做才能使其正常工作?
can anyone please tell me what can be done in order to make it work well?
顺便说一句,应用程序应该适用于Android的API 10+(低于10)。
btw, the app should work for android API 10+ (minimum 10) .
推荐答案
确定,答案是使用的setContentView到您所希望的任何布局(包括你希望的任何意见),加入那里的preferences列表视图,并为此ListView控件,调用bind和setAdapter。
ok , the answer would be to use setContentView to whatever layout you wish (including any views you wish) , add there a listView for the preferences , and for this listView , call bind and setAdapter.
我已经找到了这种解决方案通过寻找其他的解决方案,像这样的:
i've found this solution by looking at other solutions, like this one:http://kmansoft.com/2011/08/29/implementing-long-clickable-preferences/
这篇关于Android的 - 在preferenceActivity显示的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!