请建议我用它来创建它的任何做法。
查询:我创建2 - 微调来看,这里我要补充国家/城市名单,所以,就像如果我选择印度,然后我得到50项下拉视图中,问题与此是,它走的是整页的高度。
Query : I am creating 2-Spinner view , where i have to add Country/Cities list , So like if i am selecting india then i am getting 50 items inside the drop down view , problem with this is that it is taking the whole page in height .
我要什么:我想创建一个下拉视图,其中用户只能看到10项 下拉查看,其他项目将被显示,每当用户将滚动下拉视图。
What i want : I want to create a drop down view , where user can see only 10 items in the drop down view , other items will be shown whenever user will scroll the drop down view .
您可以使用反射。
Spinner spinner = (Spinner) findViewById(R.id.spinner);
try {
Field popup = Spinner.class.getDeclaredField("mPopup");
popup.setAccessible(true);
// Get private mPopup member variable and try cast to ListPopupWindow
android.widget.ListPopupWindow popupWindow = (android.widget.ListPopupWindow) popup.get(spinner);
// Set popupWindow height to 500px
popupWindow.setHeight(500);
}
catch (NoClassDefFoundError | ClassCastException | NoSuchFieldException | IllegalAccessException e) {
// silently fail...
}