Reputation: 6128
i am progrmatically adding list view to a linear layout like this:
ArrayList<Answer> ans = (ArrayList<Answer>) ques.getAnswers();
adapter = new AnswerAdapter(Test.this, ans);
ansList = new ListView(Test.this); // my list view adding dynamically
ansList.setAdapter(adapter);
ansList.setVerticalScrollBarEnabled(false);
ansList.setOnItemClickListener(cellClickListener);
ansLayout.addView(ansList);
Now the problem is it has the default divider after each item except the last item, i want the divider to be visible after the last item also.
I have looked into many questions in SO where they are adding views in the layout but i need to add programatically.
Upvotes: 0
Views: 1680
Reputation: 10856
You can add footer view in listview... so make a layout of footerview... and bind as below
View footerView = ((LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.track_footer_view, null, false);
listview.addFooterView(footerView);
so you can have footerview at end of last item..
Upvotes: 2
Reputation: 33534
- Add that separator as the footer
to your ListView
.
Eg:
View mfooter = View.inflate(MyClass.this, R.layout.imagelayout, null);
lv.addFooterView(mfooter, null, false);
Upvotes: 0