0

I'm trying to do something like the Jelly app to show multiple dialogs at once when a user clicks. Is there a way on Android to show multiple dialogs at once? So far I've only seen posts about having one dialog appear and then another based on user action. But I want them to all appear at once, similar to Jelly, and then have the user navigate through them using gestures.

Here's an image: http://www.8ms.com/wp-content/uploads/2014/01/view-answers-compose-answer-jelly.png

mikala
  • 1
  • 1
  • What? You want the users to deal with multiple `Dialog`s at one time? What exactly are you going for? – codeMagic Feb 14 '14 at 00:34
  • you can use framelayout and add your custom views above the main activity – mohammed momn Feb 14 '14 at 00:37
  • Hmm maybe framelayout could work. This [article](http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/) shows how to overlay one view on top of another. But I'm still not sure how Jelly shows multiple cards for a question for users to go through. You can see multiple cards at once. – mikala Feb 14 '14 at 06:34
  • Or maybe within a framelayout, you could have the question view (as a textview) and the row of answers on top (as a horizontal linear layout of "cards"). Then you could have the answers appear when the user clicks the question view ?? This would allow users to scroll the row of answers like in Jelly (the app, not the bean) ?? – mikala Feb 14 '14 at 06:37

1 Answers1

0

I figured this out --

Use a FrameLayout (http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/) to overlay views and have the answers appear and disappear on click.

Specifically with the Jelly example - One view is the main view (with the user's question) and then another view is the secondary view (with all of the community answers).

The secondary view starts off as hidden, so only the main view shows.

android:visibility="invisible"

Then when the user clicks the question in the main view, your OnClickListener for the main view can programmatically change the visibility of the secondary view.

view.setVisibility(View.INVISIBLE);

So the questions appear on top of the question. You can adjust the size of the secondary/question view so that you can still see the question, like in Jelly app.

The layout of the community answers is: (see code sample below)

HorizontalScrollView

--> Linear Layout

--> Custom Views (this is where each answer is shown. It could also be a Custom Dialog)

This is all within the FrameLayout.

On how to create a custom Dialog: http://about-android.blogspot.com/2010/02/create-custom-dialog.html

In your XML file, you would leave a blank space within the Linear Layout so that you could programmatically add in the answer views/dialogs because the number and content of the custom views would differ from question to question.

<HorizontalScrollView
    android:id="@+id/notes_hsv"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_marginTop="100dp"
    android:visibility="invisible" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <!-- AnswerViews are added programmatically to this LinearLayout -->

    </LinearLayout>
</HorizontalScrollView>

On adding views programmatically to a LinearLayout: Android: Add a textview to linear layout programmatically

Community
  • 1
  • 1
mikala
  • 1
  • 1