为什么我的微调器显示为this。我想以正常方式展示我的微调器。这就是我的微调器中的值太小了。并且看起来不像普通的微调值。
守则在这里
ArrayList<Organization> organizationsarray = new ArrayList<Organization>();
Organization[] users = null ;
final ArrayList<Organization> organizations = (ArrayList<Organization>)i.getSerializableExtra("organizations");
for( Organization organization : organizations ) {
Log.d(TAG , " ORGANIZATION RETRIEVED DETAIL :"+ organization ) ;
}
users = new Organization[ organizations.size() ] ;
users = organizations.toArray( users ) ;
Spinner sp = (Spinner) navigationView.getMenu().findItem(R.id.brand_spinner).getActionView();
sp.setAdapter(new SpinAdapter(this,android.R.layout.simple_spinner_dropdown_item,users));
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
value = ((Organization)parent.getItemAtPosition(position)).getId();
Toast.makeText(parent.getContext(),""+value+"",Toast.LENGTH_SHORT).show();
session = new SessionManager(getApplicationContext());
session.checkLogin();
HashMap<String, String> usertoken = session.getUserToken();
Log.d(TAG,"loading token to the temp: " +usertoken.get("token"));
Log.d(TAG,"loading values to the sharedpref: "+value);
String tokenvalue = usertoken.get("token");
session = new SessionManager(getApplicationContext());
session.createLoginSession(tokenvalue,value);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
组织类:
public class Organization implements Serializable {
private String name;
private Long id;
public Organization(){
}
public Organization(String name, Long id) {
super();
this.name = name;
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public String toString() {
System.out.println("tostring");
return "name :"+name +"|| id :"+id ;
}
}
答案 0 :(得分:0)
在layout
文件夹
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/dropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:maxLines="1"
android:padding="10dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/text_primary" />
并更改此行
sp.setAdapter(new SpinAdapter(this,android.R.layout.simple_spinner_dropdown_item,users));
到
sp.setAdapter(new SpinAdapter(this,R.layout.spinner_text,users));