2014-04-03 28 views
-1

查看下面的截圖。對於前兩個字段,我只使用ArrayAdapaters(int和String)。第三,我創建了一個自定義適配器(和自定義的Spinner對象),以便我可以顯示提示。除格式看起來不好之外,所有工作都很好。下拉項目較小,不像其他人那樣填充。此外,「信用」下方的線比其他紡紗者高。我選擇一個值後,該行將調整到應該在的位置。如何適當地設置我的微調器佈局?

我該去哪裏修復格式?高度和寬度設置與XML中的其他旋鈕相匹配。我對此比較陌生。

enter image description here

回答

0

在您自定義的微調適配器,你應該有:

public View getView(int position, View convertView, ViewGroup parent) { 

    LayoutInflater inflater = getLayoutInflater(); 
    View row = inflater.inflate(yourSelectedItemLayout, parent,false); 
    TextView make = (TextView) row.findViewById(R.id.Make); 
    v.setText(data.get(position)); 
    return row; 
} 


public View getDropDownView(int position, View convertView, ViewGroup parent) { 

    LayoutInflater inflater = getLayoutInflater(); 
    View row = inflater.inflate(yourDropDownlayoutOut, parent,false); 
    TextView make = (TextView) row.findViewById(R.id.Make); 
    v.setText(data.get(position)); 
    return row; 
} 

yourSelectedItemLayout和yourDropDownlayoutOut將佈局創建,你可以設置自己的格式。