TextView vs Button for Android AlertDialog











up vote
3
down vote

favorite












I want to open an AlertDialog on the click of either a Button or TextView but I am not sure what would work best. When a selection is made in the AlertDialog, I want the bottom text to be updated with the selection. Here are the two options I have:



TextViews only. Here, the LinearLayout will have listener and will open AlertDialog.



<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical">

<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Label" />

<TextView
android:id="@+id/selection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:textSize="18sp"
android:text="Select..." />

</LinearLayout>


TextView and Button. Here, the Button will open the AlertDialog and the text inside the Button will be replaced with the selection.



<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:text="Label"
android:textSize="16sp"
android:textColor="@android:color/white" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:layout_marginTop="-20dp"
android:text="Select..."
android:textAllCaps="false"
android:textColor="@android:color/white"
android:gravity="start|center_vertical"
android:paddingLeft="15dp"
android:paddingStart="15dp"
android:paddingRight="15dp"
android:paddingEnd="15dp"
android:paddingTop="15dp"
android:textSize="18sp"
android:background="@android:color/transparent" />









share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.



















    up vote
    3
    down vote

    favorite












    I want to open an AlertDialog on the click of either a Button or TextView but I am not sure what would work best. When a selection is made in the AlertDialog, I want the bottom text to be updated with the selection. Here are the two options I have:



    TextViews only. Here, the LinearLayout will have listener and will open AlertDialog.



    <LinearLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:orientation="vertical">

    <TextView
    android:id="@+id/label"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Label" />

    <TextView
    android:id="@+id/selection"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginStart="5dp"
    android:textSize="18sp"
    android:text="Select..." />

    </LinearLayout>


    TextView and Button. Here, the Button will open the AlertDialog and the text inside the Button will be replaced with the selection.



    <TextView
    android:id="@+id/label"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="5dp"
    android:layout_marginStart="5dp"
    android:text="Label"
    android:textSize="16sp"
    android:textColor="@android:color/white" />

    <Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/label"
    android:layout_marginTop="-20dp"
    android:text="Select..."
    android:textAllCaps="false"
    android:textColor="@android:color/white"
    android:gravity="start|center_vertical"
    android:paddingLeft="15dp"
    android:paddingStart="15dp"
    android:paddingRight="15dp"
    android:paddingEnd="15dp"
    android:paddingTop="15dp"
    android:textSize="18sp"
    android:background="@android:color/transparent" />









    share|improve this question














    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I want to open an AlertDialog on the click of either a Button or TextView but I am not sure what would work best. When a selection is made in the AlertDialog, I want the bottom text to be updated with the selection. Here are the two options I have:



      TextViews only. Here, the LinearLayout will have listener and will open AlertDialog.



      <LinearLayout
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="8dp"
      android:orientation="vertical">

      <TextView
      android:id="@+id/label"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Label" />

      <TextView
      android:id="@+id/selection"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:layout_marginStart="5dp"
      android:textSize="18sp"
      android:text="Select..." />

      </LinearLayout>


      TextView and Button. Here, the Button will open the AlertDialog and the text inside the Button will be replaced with the selection.



      <TextView
      android:id="@+id/label"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="10dp"
      android:layout_marginLeft="5dp"
      android:layout_marginStart="5dp"
      android:text="Label"
      android:textSize="16sp"
      android:textColor="@android:color/white" />

      <Button
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@id/label"
      android:layout_marginTop="-20dp"
      android:text="Select..."
      android:textAllCaps="false"
      android:textColor="@android:color/white"
      android:gravity="start|center_vertical"
      android:paddingLeft="15dp"
      android:paddingStart="15dp"
      android:paddingRight="15dp"
      android:paddingEnd="15dp"
      android:paddingTop="15dp"
      android:textSize="18sp"
      android:background="@android:color/transparent" />









      share|improve this question













      I want to open an AlertDialog on the click of either a Button or TextView but I am not sure what would work best. When a selection is made in the AlertDialog, I want the bottom text to be updated with the selection. Here are the two options I have:



      TextViews only. Here, the LinearLayout will have listener and will open AlertDialog.



      <LinearLayout
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="8dp"
      android:orientation="vertical">

      <TextView
      android:id="@+id/label"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Label" />

      <TextView
      android:id="@+id/selection"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:layout_marginStart="5dp"
      android:textSize="18sp"
      android:text="Select..." />

      </LinearLayout>


      TextView and Button. Here, the Button will open the AlertDialog and the text inside the Button will be replaced with the selection.



      <TextView
      android:id="@+id/label"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="10dp"
      android:layout_marginLeft="5dp"
      android:layout_marginStart="5dp"
      android:text="Label"
      android:textSize="16sp"
      android:textColor="@android:color/white" />

      <Button
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@id/label"
      android:layout_marginTop="-20dp"
      android:text="Select..."
      android:textAllCaps="false"
      android:textColor="@android:color/white"
      android:gravity="start|center_vertical"
      android:paddingLeft="15dp"
      android:paddingStart="15dp"
      android:paddingRight="15dp"
      android:paddingEnd="15dp"
      android:paddingTop="15dp"
      android:textSize="18sp"
      android:background="@android:color/transparent" />






      android xml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 '16 at 17:44









      Alexiz Hernandez

      88119




      88119





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Answer is Button.



          Button is a subclass of TextView. So it has all the features of TextView and additional features of Button class. Button adds a few stylistic changes (e.g., default background image, additional padding, ripple effect) to allow quicker adaptation to your designs.






          share|improve this answer





















            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "196"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f146777%2ftextview-vs-button-for-android-alertdialog%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Answer is Button.



            Button is a subclass of TextView. So it has all the features of TextView and additional features of Button class. Button adds a few stylistic changes (e.g., default background image, additional padding, ripple effect) to allow quicker adaptation to your designs.






            share|improve this answer

























              up vote
              0
              down vote













              Answer is Button.



              Button is a subclass of TextView. So it has all the features of TextView and additional features of Button class. Button adds a few stylistic changes (e.g., default background image, additional padding, ripple effect) to allow quicker adaptation to your designs.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Answer is Button.



                Button is a subclass of TextView. So it has all the features of TextView and additional features of Button class. Button adds a few stylistic changes (e.g., default background image, additional padding, ripple effect) to allow quicker adaptation to your designs.






                share|improve this answer












                Answer is Button.



                Button is a subclass of TextView. So it has all the features of TextView and additional features of Button class. Button adds a few stylistic changes (e.g., default background image, additional padding, ripple effect) to allow quicker adaptation to your designs.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '16 at 16:54









                Harish Gyanani

                25111




                25111






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Code Review Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f146777%2ftextview-vs-button-for-android-alertdialog%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Morgemoulin

                    Scott Moir

                    Souastre