2015-05-19 58 views
7

我的Android項目構建目標是5.1.1 API 22棒棒糖上的微調器故障

此應用程序似乎適用於除棒棒糖以外的每個操作系統版本。棒棒糖重新調整了一些活動的高度(否定了可滾動的佈局),並擾亂了紡紗者。

單擊微調框上的特定位置將在應用中輸入不同的位置。我不知道爲什麼,我不知道如何解決這個問題。在某些情況下,即使您單擊微調器上的按鈕,它也會在微調器上註冊最下方最顯眼的按鈕。對於某些紡紗廠來說,它不會允許用戶滾動。

我的一個故障代碼微調是這樣的:

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); 

我也使用全局變量的函數displayData嘗試,但我仍然得到同樣的結果。

該應用程序是一個非常基本的應用程序,你可以下載here和Java編譯器符合水平運行1.7

我的XML的開始是這樣的:

<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])); 
} 
+0

有什麼方法'displayData'呢? – fRoStBiT

+0

@fRoStBiT它只是爲一些textviews設置文本 – krikara

+0

你爲什麼要在'isEnabled()'中做它?你應該在'getView()'中做到這一點。 – fRoStBiT

回答

3

問題出在這裏:

ArrayAdapter<String>adapterl4 = new ArrayAdapter<String>(this, 
     android.R.layout.simple_spinner_item,hbmlevel){ 
      public boolean isEnabled(int position){ 
       displayData(position); 
       return true; 
      } 
     }; 

isEnabled函數根本不適用於棒棒糖。解決方法是將selecthbm.setOnItemSelectedListener(this);更改爲selecthbm.setOnItemSelectedListener(new OnItemSelectedListener(){...});,並刪除isEnabled函數的全部內容。

我不知道爲什麼isEnabled函數不起作用。如果有人想提供解釋,我可以獎勵賞金。