In your fragment's onCreateView
, you're reinflating the layout and returning new view. This new view doesn't have any idea about lv
.
Solution:
Return v
instead of inflater.inflate(R.layout.list_view_fragment, container, false);
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Course Queries 4 Answers
Course Queries 5 Answers
Course Queries 1 Answers
Course Queries 3 Answers
Course Queries 4 Answers
manpreet
Best Answer
2 years ago
I am passing an object from
MainActivity
toGradeListActivity
. InGradeListActivity
I have aFragment
(which contains aListView
). I am trying to populate thisListView
but whenever my app runs,GradListActivity
is blank.I debugged my program to make sure the object is being passed to the
GradeListActivity
andListViewfragment
(the fragment class), and it is indeed being passed in. I think i might be not populating the list in the correct place, but any help or guidance will be much appreciated.My MainActivity.java: