Set value from Firebase Realtime Database to RadioButton












0















Is there a way I can set a RadioButton with a string value in my Firebase Realtime Database? Is it possible? Below is my code.



DatabaseReference questions_beg_java = FirebaseDatabase.getInstance().getReference().child("Questions").child("BeginnerJava").child("QuestionOne");
questions_beg_java.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

String question_one = dataSnapshot.child("question_one").getValue().toString();
String answer_one = dataSnapshot.child("answer_one").getValue().toString();
String answer_two = dataSnapshot.child("answer_two").getValue().toString();
String answer_three = dataSnapshot.child("answer_three").getValue().toString();

//radioButton1.
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});


What do I add to set a value to the RadioButton? As in retrieving it from Firebase Realtime Database?










share|improve this question

























  • How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

    – Grimthorr
    Nov 15 '18 at 15:03











  • I am having a string value in my database And I want to give the radiobutton the same name as the string value.

    – Perfect Updates
    Nov 15 '18 at 15:12











  • The Android RadioButton view inherits from TextView, so you can use setText().

    – Grimthorr
    Nov 15 '18 at 15:22











  • This is shameful. Thanks a lot bro

    – Perfect Updates
    Nov 15 '18 at 15:24











  • Glad I could help, I'll add it as an answer for you.

    – Grimthorr
    Nov 15 '18 at 15:43
















0















Is there a way I can set a RadioButton with a string value in my Firebase Realtime Database? Is it possible? Below is my code.



DatabaseReference questions_beg_java = FirebaseDatabase.getInstance().getReference().child("Questions").child("BeginnerJava").child("QuestionOne");
questions_beg_java.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

String question_one = dataSnapshot.child("question_one").getValue().toString();
String answer_one = dataSnapshot.child("answer_one").getValue().toString();
String answer_two = dataSnapshot.child("answer_two").getValue().toString();
String answer_three = dataSnapshot.child("answer_three").getValue().toString();

//radioButton1.
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});


What do I add to set a value to the RadioButton? As in retrieving it from Firebase Realtime Database?










share|improve this question

























  • How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

    – Grimthorr
    Nov 15 '18 at 15:03











  • I am having a string value in my database And I want to give the radiobutton the same name as the string value.

    – Perfect Updates
    Nov 15 '18 at 15:12











  • The Android RadioButton view inherits from TextView, so you can use setText().

    – Grimthorr
    Nov 15 '18 at 15:22











  • This is shameful. Thanks a lot bro

    – Perfect Updates
    Nov 15 '18 at 15:24











  • Glad I could help, I'll add it as an answer for you.

    – Grimthorr
    Nov 15 '18 at 15:43














0












0








0








Is there a way I can set a RadioButton with a string value in my Firebase Realtime Database? Is it possible? Below is my code.



DatabaseReference questions_beg_java = FirebaseDatabase.getInstance().getReference().child("Questions").child("BeginnerJava").child("QuestionOne");
questions_beg_java.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

String question_one = dataSnapshot.child("question_one").getValue().toString();
String answer_one = dataSnapshot.child("answer_one").getValue().toString();
String answer_two = dataSnapshot.child("answer_two").getValue().toString();
String answer_three = dataSnapshot.child("answer_three").getValue().toString();

//radioButton1.
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});


What do I add to set a value to the RadioButton? As in retrieving it from Firebase Realtime Database?










share|improve this question
















Is there a way I can set a RadioButton with a string value in my Firebase Realtime Database? Is it possible? Below is my code.



DatabaseReference questions_beg_java = FirebaseDatabase.getInstance().getReference().child("Questions").child("BeginnerJava").child("QuestionOne");
questions_beg_java.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

String question_one = dataSnapshot.child("question_one").getValue().toString();
String answer_one = dataSnapshot.child("answer_one").getValue().toString();
String answer_two = dataSnapshot.child("answer_two").getValue().toString();
String answer_three = dataSnapshot.child("answer_three").getValue().toString();

//radioButton1.
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});


What do I add to set a value to the RadioButton? As in retrieving it from Firebase Realtime Database?







java android firebase firebase-realtime-database android-radiobutton






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 15:48









Grimthorr

4,47442237




4,47442237










asked Nov 15 '18 at 14:57









Perfect UpdatesPerfect Updates

33




33













  • How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

    – Grimthorr
    Nov 15 '18 at 15:03











  • I am having a string value in my database And I want to give the radiobutton the same name as the string value.

    – Perfect Updates
    Nov 15 '18 at 15:12











  • The Android RadioButton view inherits from TextView, so you can use setText().

    – Grimthorr
    Nov 15 '18 at 15:22











  • This is shameful. Thanks a lot bro

    – Perfect Updates
    Nov 15 '18 at 15:24











  • Glad I could help, I'll add it as an answer for you.

    – Grimthorr
    Nov 15 '18 at 15:43



















  • How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

    – Grimthorr
    Nov 15 '18 at 15:03











  • I am having a string value in my database And I want to give the radiobutton the same name as the string value.

    – Perfect Updates
    Nov 15 '18 at 15:12











  • The Android RadioButton view inherits from TextView, so you can use setText().

    – Grimthorr
    Nov 15 '18 at 15:22











  • This is shameful. Thanks a lot bro

    – Perfect Updates
    Nov 15 '18 at 15:24











  • Glad I could help, I'll add it as an answer for you.

    – Grimthorr
    Nov 15 '18 at 15:43

















How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

– Grimthorr
Nov 15 '18 at 15:03





How do you want to set the RadioButton? Which value from the database should be used? Could you use a switch statement?

– Grimthorr
Nov 15 '18 at 15:03













I am having a string value in my database And I want to give the radiobutton the same name as the string value.

– Perfect Updates
Nov 15 '18 at 15:12





I am having a string value in my database And I want to give the radiobutton the same name as the string value.

– Perfect Updates
Nov 15 '18 at 15:12













The Android RadioButton view inherits from TextView, so you can use setText().

– Grimthorr
Nov 15 '18 at 15:22





The Android RadioButton view inherits from TextView, so you can use setText().

– Grimthorr
Nov 15 '18 at 15:22













This is shameful. Thanks a lot bro

– Perfect Updates
Nov 15 '18 at 15:24





This is shameful. Thanks a lot bro

– Perfect Updates
Nov 15 '18 at 15:24













Glad I could help, I'll add it as an answer for you.

– Grimthorr
Nov 15 '18 at 15:43





Glad I could help, I'll add it as an answer for you.

– Grimthorr
Nov 15 '18 at 15:43












1 Answer
1






active

oldest

votes


















1














The Android RadioButton widget is basically a TextView with some extra styling and functionality. It is therefore inheriting all methods from TextView, including setText().



This means that you can do something like:



String answer_one = dataSnapshot.child("answer_one").getValue().toString();
radioButton1.setText(answer_one);





share|improve this answer























    Your Answer






    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: "1"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f53322194%2fset-value-from-firebase-realtime-database-to-radiobutton%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









    1














    The Android RadioButton widget is basically a TextView with some extra styling and functionality. It is therefore inheriting all methods from TextView, including setText().



    This means that you can do something like:



    String answer_one = dataSnapshot.child("answer_one").getValue().toString();
    radioButton1.setText(answer_one);





    share|improve this answer




























      1














      The Android RadioButton widget is basically a TextView with some extra styling and functionality. It is therefore inheriting all methods from TextView, including setText().



      This means that you can do something like:



      String answer_one = dataSnapshot.child("answer_one").getValue().toString();
      radioButton1.setText(answer_one);





      share|improve this answer


























        1












        1








        1







        The Android RadioButton widget is basically a TextView with some extra styling and functionality. It is therefore inheriting all methods from TextView, including setText().



        This means that you can do something like:



        String answer_one = dataSnapshot.child("answer_one").getValue().toString();
        radioButton1.setText(answer_one);





        share|improve this answer













        The Android RadioButton widget is basically a TextView with some extra styling and functionality. It is therefore inheriting all methods from TextView, including setText().



        This means that you can do something like:



        String answer_one = dataSnapshot.child("answer_one").getValue().toString();
        radioButton1.setText(answer_one);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 15:47









        GrimthorrGrimthorr

        4,47442237




        4,47442237
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f53322194%2fset-value-from-firebase-realtime-database-to-radiobutton%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

            Bressuire

            Vorschmack

            Quarantine