I have got a actionbar spinner example project. It is working fine. Now I am trying change few things like:
When I open my app the spinner shows the following:
Local subitem is choosen by default which is fine but I would like to change the Local text to something else when I choose item Local is this possible?
When I open the app? By default it shows the first item text like screen above. I want to change something like TITLE will be ITEMS and Sub title will be SubItems (Default selection of first Item is fine - just that I don't want to show Local text instead I want to show SubItems.
Now it shows ITEMS and Local - This Local text should only be changed when I click Local Item from the spinner.
The text when the spinner expands with items should be the same. like below:
I think it can possible in Adapter but not sure how:
Here is my customAdapter java file:
public class SubItemNavigationAdapter extends BaseAdapter
{
private TextView txtTitle;
private ArrayList<SpinnerNavItem> spinnerNavItem;
private Context context;
private TextView txtHeading;
public SubItemNavigationAdapter(Context context, ArrayList<SpinnerNavItem> spinnerNavItem)
{
this.spinnerNavItem = spinnerNavItem;
this.context = context;
}
@Override
public int getCount()
{
return spinnerNavItem.size();
}
@Override
public Object getItem(int index)
{
return spinnerNavItem.get(index);
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_item_title_navigation, null);
}
txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
txtTitle.setText(spinnerNavItem.get(position).getTitle());
return convertView;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_item_title_navigation, null);
}
txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
txtTitle.setPadding(20, 20, 0, 20);
txtHeading = (TextView) convertView.findViewById(R.id.txtheading);
txtHeading.setVisibility(View.GONE);
txtTitle.setText(spinnerNavItem.get(position).getTitle());
return convertView;
}
}
Let me know!
Thanks!