我首先搜索将adapter
设置为LinearLayout
但是因为它不可能所以我使用它:
LinearLayout LinearLayout = (LinearLayout) findViewById(R.id.linearLayoutListeNote);
//LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(this);
List<NoteObjet> notes = new ArrayList<NoteObjet>();
notes.add(new NoteObjet(Color.BLACK, "Kevin"));
notes.add(new NoteObjet(Color.BLUE, "Kevin"));
notes.add(new NoteObjet(Color.GREEN, "Logan"));
notes.add(new NoteObjet(Color.RED, "Mathieu"));
notes.add(new NoteObjet(Color.GRAY, "Willy"));
for (NoteObjet objet : notes){
View view = inflater.inflate(R.layout.noteadapter, LinearLayout, false);
// set item content in view
LinearLayout.addView(view);
}