- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个从 ArrayAdapter 扩展的适配器,以便用一个对象集合(城市)填充一个 Spinner。所有对象和适配器都可以正常工作,至少看起来是这样。问题是当我显示所有城市集合时,它显示为向上而不是向下。
有人知道会发生什么吗?
这是我的适配器
public class AdapterSpinnerListCities extends ArrayAdapter<City> {
// My context
private Context context;
// Values for the spinner (City)
private List<City> listLocationsSpinner = UpdatedStatusApplication.getListLocations();
Typeface tf = null;
public AdapterSpinnerListCities (Context context, int textViewResourceId, List<City> listLocationsAPP) {
super(context, textViewResourceId, listLocationsAPP);
this.context = context;
this.listLocationsSpinner = listLocationsAPP;
tf = CustomFontsLoader.getTypeface(this.context,CustomFontsLoader.FONT_CHALKBOARD_1);
}
public int getCount(){
return listLocationsSpinner.size();
}
public City getItem(int position){
return listLocationsSpinner.get(position);
}
public long getItemId(int position){
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item = convertView;
item = inflater.inflate(R.layout.list_item_city, null);
TextView tvCity = (TextView)item.findViewById(R.id.tv_item_city);
tvCity.setText(listLocationsSpinner.get(position).getCityName().toUpperCase());
tvCity.setTypeface(tf);
return(item);
}
// And here is when the "chooser" is popped up
// Normally is the same view, but you can customize it if you want
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item = convertView;
if (listLocationsSpinner.get(position).getCitySubcity() == TagManager.TAG_IS_NOT_SUBCITY){
item = inflater.inflate(R.layout.list_item_city, null);
TextView tvCity = (TextView)item.findViewById(R.id.tv_item_city);
tvCity.setText(listLocationsSpinner.get(position).getCityName().toUpperCase());
tvCity.setTypeface(tf);
}
else{
item = inflater.inflate(R.layout.list_item_subcity, null);
TextView tvSubCity = (TextView)item.findViewById(R.id.tv_item_subcity);
tvSubCity.setText(listLocationsSpinner.get(position).getCityName());
tvSubCity.setTypeface(tf);
}
return(item);
}
布局中的我的 Spinner(它是一个 RelativeLayout)
<LinearLayout
android:id="@+id/lyt_locationSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/LinearLayoutLogo"
android:layout_below="@+id/lyt_drink_food_deals"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
>
<Spinner android:id="@+id/cmb_location"
style="@style/style_btn_request"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:spinnerMode="dropdown"
/>
</LinearLayout>
我的 Activity
private Spinner mySpinner;
private AdapterSpinnerListCities adapter;
List<City> listDeployedLocations = new ArrayList<City>();
.....
.....
adapter = new AdapterSpinnerListCities (this, android.R.layout.simple_spinner_dropdown_item, listDeployedLocations);
mySpinner = (Spinner) findViewById(R.id.cmb_location);
mySpinner.setAdapter(adapter); // Set the custom adapter to the spinner
mySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected (AdapterView<?> parentView, View selectedItemView, int position, long id) {
citySelected = listDeployedLocations.get(position);
System.out.println("Spinner value...."+ citySelected.getCityID()+"-"+citySelected.getCityName());
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// code here
}
});
最佳答案
如果使微调器充气的元素靠近屏幕底部,就会发生这种情况。由于如果向下充气旋转器将没有足够的空间(或几乎没有足够的空间),因此它会向上充气。尝试将微调器放在布局中更高(垂直)的位置。
关于android - Spinner dropUP 而不是 dropDOWN android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16910565/
我想制作一个带“下拉”菜单的导航栏,并带有词缀属性。但是当'.affix'被触发时,'dropup'菜单将变成'dropdown'。我的 JS 代码无法正常工作,无法为此获得任何解决方案。我的代码在下
我正在尝试实现一个下拉菜单。作为起点,我使用基于 CSS 技巧的简单 jQuery 下拉菜单的 HTML/CSS/jQuery 构建的现有下拉菜单。 (因为我无法在触摸设备上使用纯 css,因为它们依
无论下方是否有足够的空间,我都希望每次都向上显示下拉列表。 如何实现?这样做的关键点是什么? 更新 下面是我如何初始化 Select2: $("select[name=ingredients]").s
dropdown-item class仅在使用dropdown class时才能正常工作,但在dropup class中不起作用。 单击所有子菜单项后,下拉菜单不起作用。因为每次点击后,所有下拉项都会
我的 footer 中的 dropup 不工作。当我将 dropup 更改为 dropdown 时,它开始作为 dropdown 工作,但我需要一个 dropup。我遵循了 bootstrap 的指导
我的移动页脚上有一个下拉按钮,但下拉按钮仅在悬停时打开。 如何更改下拉菜单仅在单击时可见的代码? More
我正在尝试使用具有简单自动完成功能的 Bootstrap 下拉菜单。下拉菜单不会出现此问题,只会出现下拉菜单。 我在这里的 JSFiddle 中复制了这个问题:https://jsfiddle.net
我有一个 Bootstrap 下拉菜单。最后一个 li 项是一个子菜单。如何在整个菜单下拉时让子菜单下拉?这是代码: FILTER Tex
我需要使用下拉菜单。 此代码与 ui-bootstrap-tpls-0.10.0.js 完美配合: {{text}} Toggle Dropdow
使用 Twitter Bootstrap,.carousel-inner 样式预设为: .carousel-inner { position: relative; width: 100%;
我有一个从 ArrayAdapter 扩展的适配器,以便用一个对象集合(城市)填充一个 Spinner。所有对象和适配器都可以正常工作,至少看起来是这样。问题是当我显示所有城市集合时,它显示为向上而不
我想在 Angular.js 中实现一个下拉菜单(在按钮上方打开的菜单),其行为类似于 Boostrap 中的“.dropup”类。 是否有执行此操作的指令或创建指令的简单指令? 最佳答案 如果您使用
我试图将以下内容作为页脚对齐,但下拉菜单与其余内容不对齐:
我有一个固定在底部的菜单,并希望切换为下拉而不是向下。我已经尝试了在 stackoverflow 中找到的所有解决方案(比如这个 How to get a Bootstrap dropdown sub
我正在 github pages 上做一个元素,如果 div 的 overflow-y: scroll,我用 .dropup 替换 Bootstrap .dropdown 将导致下拉菜单被 chop/
我正在使用 Bootstrap Select 为 Accordion 内的一些选择字段设置样式。 Bootstrap select 有一个功能,如果它靠近屏幕底部,它将使您的下拉菜单成为下拉菜单。 在
在发布之前,我已经研究了该解决方案的站点。似乎没有一种方法适用于这种方法。 我在中创建了以下模板Pingendo. .dropup .dropdown-menu { top: auto; bo
下面是我的 html: Hi! LI 1 根据文档,我尝试过: $("div.dropup").on("show", fun
我正在使用这个:http://jsfiddle.net/fJSVz/作为我的基本菜单,它非常适合底部固定菜单。也就是说,我需要显示当您将鼠标悬停在要显示在上方、居中和内联(在一行上)的菜单上时出现的二
我是一名优秀的程序员,十分优秀!