微调错误的棒棒糖 [英] Spinner malfunctioning on Lollipop
问题描述
我的Android项目建设目标是5.1.1 API 22
该应用程序似乎除了为每个棒棒糖OS版本。棒棒糖调整了一些活动的高度(否定滚动布局)以及扰乱了心思。
点击一个微调将输入应用程序的不同位置的特定位置。我不知道为什么,我不知道如何解决这个问题。在某些情况下,即使你点击微调按钮,它注册的微调底部最明显的按钮。对于一些微调,它不会让用户在所有滚动。
我的一个发生故障的微调codeS的是这样的:
ArrayAdapter<串GT; adapterl4 =新ArrayAdapter<串GT;(这一点,
android.R.layout.simple_spinner_item,hbmlevel){
公共布尔isEnabled(INT位置){
displayData(位置);
返回true;
}
};
selecthbm =(微调)findViewById(R.id.selecthbmlvl);
adapterl4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selecthbm.setAdapter(adapterl4);
selecthbm.setOnItemSelectedListener(本);
我也使用全局变量的函数试图 displayData code>,但我仍然得到同样的结果。
该应用程序是一个非常基本的应用程序,你可以在这里下载 并运行在Java编译器符合水平1.7
我的XML的开始是这样的:
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =FILL_PARENT
的xmlns:广告=http://schemas.android.com/apk/res-auto
机器人:fillViewport =真
机器人:背景=#C2DFFF><的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
displayData:
公共无效displayData(INT POS){ herolvlTV.setText(hbmherolvl [POS]);
hbmshardTV.setText(getResources()的getString(R.string.shards)++将String.valueOf(hbmshards [POS]));
hbmexpTV.setText(getResources()的getString(R.string.maxexp)++将String.valueOf(hbmmaxexp [POS]));
}
下面的问题:
ArrayAdapter<串GT; adapterl4 =新ArrayAdapter<串GT;(这一点,
android.R.layout.simple_spinner_item,hbmlevel){
公共布尔isEnabled(INT位置){
displayData(位置);
返回true;
}
};
的 isEnabled
功能根本就不在棒棒糖工作。解决的办法是改变 selecthbm.setOnItemSelectedListener(本);
到 selecthbm.setOnItemSelectedListener(新OnItemSelectedListener(){...});
和删除 isEnabled
功能的全部。
我不知道为什么 isEnabled
功能不工作,虽然。如果有人想提供一个解释,我能获奖赏金。
My Android Project Build Target is 5.1.1 API 22
This app seems to work for every OS version except Lollipop. Lollipop restructures the height of some activities (negating the scrollable layout) as well as disrupts the spinners.
Clicking a specific position on a spinner will input a different position in the app. I'm not sure why and I don't know how to fix this. In some cases, even if you click a button on the spinner, it registers the bottom most visible button on the spinner. For some spinners, it won't allow the user to scroll at all.
One of my malfunctioning spinner codes is like this:
ArrayAdapter<String>adapterl4 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,hbmlevel){
public boolean isEnabled(int position){
displayData(position);
return true;
}
};
selecthbm = (Spinner)findViewById(R.id.selecthbmlvl);
adapterl4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selecthbm.setAdapter(adapterl4);
selecthbm.setOnItemSelectedListener(this);
I've also tried using a global variable for the function displayData
but I still get the same results.
The app is a very basic app that you can download here and is running on Java Compiler Compliance level 1.7
The beginning of my xml looks like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:fillViewport="true"
android:background="#C2DFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
displayData:
public void displayData(int pos){
herolvlTV.setText(hbmherolvl[pos]);
hbmshardTV.setText(getResources().getString(R.string.shards)+" " +String.valueOf(hbmshards[pos]));
hbmexpTV.setText(getResources().getString(R.string.maxexp)+" " +String.valueOf(hbmmaxexp[pos]));
}
Here's the issue :
ArrayAdapter<String>adapterl4 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,hbmlevel){
public boolean isEnabled(int position){
displayData(position);
return true;
}
};
The isEnabled
function simply does not work on Lollipop. The solution is to change selecthbm.setOnItemSelectedListener(this);
into selecthbm.setOnItemSelectedListener(new OnItemSelectedListener(){...});
and remove the isEnabled
function in its entirety.
I don't know why the isEnabled
function doesn't work though. If anyone wants to provide an explanation, I can award the bounty.
这篇关于微调错误的棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!