I have a spinner getting views from a custom base adapter. The problem is when the spinner is displayed the font colour ALWAYS seems like its disabled, whether it is disabled or not. I have searched and searched for the solution but couldn’t find any. It wasn’t like this when I developed for other platforms. Currently I am on android 3.1 honeycomb galaxy tab 10.1 . PLEASE. HELP! Thanks!!
It worked well when i use the simple spinner dropdown item for a single text display so everything looks like its messed up. part of the page looks normal and part of it looks disabled.
Adapter item view
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="@+id/lblEmployeeIdentifier"
style="@style/FormText" />
<TextView
style="@style/FormText"
android:text=" - " />
<TextView
android:id="@+id/lblEmployeeName"
style="@style/FormText" />
</LinearLayout>
And the adapter code
public class EmployeeAdapter extends BaseAdapter
{
Employee[] employee;
int role;
boolean allActive;
public EmployeeAdapter(int role, boolean allActive)
{
this.role = role;
this.allActive = allActive;
refreshData();
}
private void refreshData()
{
DatabaseAdapter databaseAdapter = MainApplication.getDatabaseAdapter();
databaseAdapter.open();
employee = databaseAdapter.getEmployeesByRole(role, allActive);
databaseAdapter.close();
}
@Override
public void notifyDataSetChanged() {
refreshData();
super.notifyDataSetChanged();
}
@Override
public int getCount() {
return employee.length;
}
@Override
public Employee getItem(int position) {
return employee[position];
}
@Override
public long getItemId(int position) {
return employee[position].getEmployeeId();
}
@Override
public View getView(int position , View convertView, ViewGroup parent) {
View view;
if (convertView != null)
{
view = convertView;
}
else
{
view = LayoutInflater.from(MainApplication.getContext()).inflate(R.layout.employee_adapter_view_1, null);
}
TextView lblIdentifier = (TextView)view.findViewById(R.id.lblEmployeeIdentifier);
TextView lblName = (TextView)view.findViewById(R.id.lblEmployeeName);
lblIdentifier.setText(employee[position].getEmployeeIdentifier());
lblName.setText(employee[position].getFirstName() + " " + employee[position].getLastName());
return view;
}
}
Delete
MainApplication.getContext()and use anActivity.Then, temporarily replace
R.layout.employee_adapter_view_1withandroid.R.layout.simple_spinner_itemand adjust yourTextViewupdates to match. If theSpinnernow behaves properly, your problem is in your primary adapter layout (R.layout.employee_adapter_view_1).If by:
you mean that when the
Spinneris opened (via the drop-down arrow) the entries in the list appear disabled, then the problem is with the layout you are using in your missinggetDropDownView()implementation inEmployeeAdapter.