1

When display data from HasMap with key and value in Spinner it appear in one line. So how can I display data from HashMap in multiple line?

This is my try.

mydb = new DBHelper(this);
Studentcourses=(Spinner)findViewById(R.id.spinner);

HashMap<Integer,String> courses=mydb.getAllStudent_Course(std_id);

ArrayAdapter<HashMap<Integer, String>> adapter = new ArrayAdapter<HashMap<Integer,String>>(this, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.add(courses);
Studentcourses.setAdapter(adapter);
frogatto
  • 28,539
  • 11
  • 83
  • 129

1 Answers1

1

ArrayAdapter by its own can't write two lines, besides you use android.R.layout.simple_spinner_item so you need to make own custom adapter like there

http://android-er.blogspot.com/2013/06/custom-arrayadapter-for-spinner-with.html

(just change the imageView to textview in layout)

frogatto
  • 28,539
  • 11
  • 83
  • 129
Dmytro Chaban
  • 1,106
  • 1
  • 11
  • 19