Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

ahmet yuva
ahmet yuva
17,595 Points

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 ;)