Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Lists and Adapters (2015) Acting on List Item Taps Tapping on a ListView Item

how can i make a new activity when user click one hour and appears SingleDetailHourActivity ?

i have a problem, when user click one of day or hour i would like to see detailHourActivity i mean in this activity onItemClick i wanna get jsondata which belongs to only this hour which is clicked by user, how can i do that.

1 Answer

George Pirchalaishvili
George Pirchalaishvili
3,747 Points

So what you need to do is to add Extra to Intent which leads to next activity. You did same when you went from main activity to hourly activity in your weather app.

When user clicks on a list, you also get a number of the line he clicked on. Since you have array of hours (mHours[]), you can use that position as an indicator of which hour to choose (mHours[position]).

Hope this makes sence ;)