fweigl
fweigl

Reputation: 22028

Right way to implement this layout?

Here's what I want to do in an app, hope it's clear:

enter image description here

NOTE: I don't want to have all 3 views on the screen at once!

I have a search window, I have results, and I want to show details about a result item when it's clicked. On a small screen (phone) it's pretty clear: I show one view at a time.

On a tablet, especially in landscape mode I'd like to show 2 views at a time, means:

[search | results] and when a result item is clicked, show [results | item detail].

My ideas:

  1. Have an Activity "SearchAndResults", when result item is clicked, open another Activity calles ResultsAndDetails. Both Activities would use Fragments, eg SearchFragment, ResultFragment, DetailFragment. This might be quite easy to implement but doesn't seem very elegant to me, especially because I can't have any animation (let the result view slide to the left, let the detail view slide in from the right)

  2. Have all 3 view in one activity and hide/ show them with layout.setvisibility(). No animations either, and I hate to do too much layout stuff in my code.

  3. A viewpager that shows 2 views, but can't be swiped by the user, only from code?

What's a good way to do this?

Upvotes: 1

Views: 134

Answers (1)

Anton Cherkashyn
Anton Cherkashyn

Reputation: 5859

I would use Fragments, as in your idea #1. This question seems to be describing the exact same type of layout that you are trying to implement. It has several answers on how to animate fragment transitions, including complete code examples.

Upvotes: 1

Related Questions