I am rather new at Android and am having some issues in understanding the usage of cwac-MergeAdapter.
I am trying to use MergeAdapter to populate a spinner; my instance of MergeAdapter should include a SimpleCursorAdapter, which is correctly reading data from my db, and (as a footer) a new TextView (or Button) which should be clickable.
Currently, if I feed the spinner the mergeAdapter containing only data from the db, everything works like a charm; however, as I add the new view, I only get a single, blank entry in the whole spinner. Can someone please help me with this?
Here follows the code:
essenceItems = new SimpleCursorAdapter(this, R.layout.db_row_view,
essenceCursor, from, to);
TextView addEssence = new TextView(getApplicationContext());
addEssence.setTextColor(R.color.red);
addEssence.setText("Add new item...");
addEssence.setWidth(ViewGroup.LayoutParams.FILL_PARENT);
addEssence.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
addEssence.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivityForResult(new Intent(v.getContext(),
EssencePopup.class), ADD_ESSENCE);
}
});
ma = new MergeAdapter();
ma.addAdapter(essenceItems);
ma.addView(addEssence, true);
spinner.setAdapter(ma);