简体   繁体   中英

Adding new listview to current listview item?

I'm newbie on android development and developing a app to improve myself. My app is listing students from db with ListView. I want to do"When I click the name of student, it will show the exam grades" I mean,I want to add new listview to onclick of list item.

Is it possible? What I need to do that(in xml and code),Do you have any code sample?

If you want to show the grades in a separate screen, I would suggest that you'll create a new Activity with it's own layout (that will contain the grades ListView ) and when a click on a student name will occur you will start the new Activity to display grades (you can pass the student id on the new Activity Intent ).

You can also consider using Fragment s. This way you will be able to change the layout to master-detail view (like in mail apps) easily on tablets. You can start by looking at this link .

Create a custom listview ( http://www.vogella.com/articles/AndroidListView/article.html ) Add a listview to the listview item and set its visibility to GONE. When they click the item set the visibility to VISIBLE.

Add an OnItemClickListener listener in the current ListView and when you get the click event query your data base for that particular student to get result. Once you have result you can load a new ListView in same Activity using Fragment or in a totally new fragment. (You are already using a ListView , so obviously you know how to load data in ListView ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM