I managed to resolve this issue, below are my code.
Basically, populate a ArrayAdapter with the list of objects from the
queryForAll then inside OnItemSelectedListener get the select objected
from the position inside the adapter.
private void refreshScreen()
{
try
{
publicationDao = this.getHelper().getPublicationDao();
Spinner spinner =
(Spinner)
aq.id(R.id.publicationSpinner).getSpinner();
List<Publication> publicationList = publicationDao.queryForAll();
final ArrayAdapter<Publication> adapter =
new ArrayAdapter<Publication>(
this,
android.R.layout.simple_spinner_item);
for (Publication publication : publicationList) {
adapter.add(publication);
}
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
public void onItemSelected(
AdapterView<?> parent,
View view,
int position,
long id) {
Publication publication =
adapter.getItem(position);
currentPublication = publication;
showPublicationDetail(currentPublication);
}
public void onNothingSelected(AdapterView<?>
parent) {
}
}
);
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
On Dec 18 2011, 6:56 pm, Robert Bui <
robertqh...@gmail.com> wrote:
> Hello,
> Anyone know a way to populate a spinner with the ORMLite returned
> list of objects. I have read the post about
> OrmLiteSimpleCursorAdapter,
http://groups.google.com/group/ormlite-android/browse_thread/thread/3...,