display data in TextView











up vote
-1
down vote

favorite












public List<UserDataHelper> getData() {
List<UserDataHelper> list = new ArrayList<UserDataHelper>();
String selectQuery = "SELECT * FROM " + TABLE;
dbase = this.getReadableDatabase();
Cursor cursor = dbase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
UserDataHelper quest = new UserDataHelper();
quest.setID(cursor.getInt(0));
quest.setName(cursor.getString(1));
quest.setSent(cursor.getInt(2));
quest.setRecieved(cursor.getInt(3));
quest.setTotal(cursor.getInt(4));
quest.setTimeSpent(cursor.getString(5));
list.add(quest);
} while (cursor.moveToNext());
}
return list;
}


This is for a listView but I want to fetch data individually and display it in textView. How can I achieve that? There are a lot of tutorials for listviews but not for textViews so can someone help me out please.










share|improve this question




















  • 1




    Possible duplicate of Android SQLite Database : How to query for a specific data?
    – 0X0nosugar
    Nov 11 at 15:02










  • it doesn't talk about displaying it in textview @0X0nosugar
    – user10238140
    Nov 11 at 15:04










  • Do you know how to display "Hello World" in a TextView?
    – 0X0nosugar
    Nov 11 at 15:05















up vote
-1
down vote

favorite












public List<UserDataHelper> getData() {
List<UserDataHelper> list = new ArrayList<UserDataHelper>();
String selectQuery = "SELECT * FROM " + TABLE;
dbase = this.getReadableDatabase();
Cursor cursor = dbase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
UserDataHelper quest = new UserDataHelper();
quest.setID(cursor.getInt(0));
quest.setName(cursor.getString(1));
quest.setSent(cursor.getInt(2));
quest.setRecieved(cursor.getInt(3));
quest.setTotal(cursor.getInt(4));
quest.setTimeSpent(cursor.getString(5));
list.add(quest);
} while (cursor.moveToNext());
}
return list;
}


This is for a listView but I want to fetch data individually and display it in textView. How can I achieve that? There are a lot of tutorials for listviews but not for textViews so can someone help me out please.










share|improve this question




















  • 1




    Possible duplicate of Android SQLite Database : How to query for a specific data?
    – 0X0nosugar
    Nov 11 at 15:02










  • it doesn't talk about displaying it in textview @0X0nosugar
    – user10238140
    Nov 11 at 15:04










  • Do you know how to display "Hello World" in a TextView?
    – 0X0nosugar
    Nov 11 at 15:05













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











public List<UserDataHelper> getData() {
List<UserDataHelper> list = new ArrayList<UserDataHelper>();
String selectQuery = "SELECT * FROM " + TABLE;
dbase = this.getReadableDatabase();
Cursor cursor = dbase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
UserDataHelper quest = new UserDataHelper();
quest.setID(cursor.getInt(0));
quest.setName(cursor.getString(1));
quest.setSent(cursor.getInt(2));
quest.setRecieved(cursor.getInt(3));
quest.setTotal(cursor.getInt(4));
quest.setTimeSpent(cursor.getString(5));
list.add(quest);
} while (cursor.moveToNext());
}
return list;
}


This is for a listView but I want to fetch data individually and display it in textView. How can I achieve that? There are a lot of tutorials for listviews but not for textViews so can someone help me out please.










share|improve this question















public List<UserDataHelper> getData() {
List<UserDataHelper> list = new ArrayList<UserDataHelper>();
String selectQuery = "SELECT * FROM " + TABLE;
dbase = this.getReadableDatabase();
Cursor cursor = dbase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
UserDataHelper quest = new UserDataHelper();
quest.setID(cursor.getInt(0));
quest.setName(cursor.getString(1));
quest.setSent(cursor.getInt(2));
quest.setRecieved(cursor.getInt(3));
quest.setTotal(cursor.getInt(4));
quest.setTimeSpent(cursor.getString(5));
list.add(quest);
} while (cursor.moveToNext());
}
return list;
}


This is for a listView but I want to fetch data individually and display it in textView. How can I achieve that? There are a lot of tutorials for listviews but not for textViews so can someone help me out please.







java android sql sqlite textview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 15:04









Mostafa Arian Nejad

525416




525416










asked Nov 11 at 14:59







user10238140















  • 1




    Possible duplicate of Android SQLite Database : How to query for a specific data?
    – 0X0nosugar
    Nov 11 at 15:02










  • it doesn't talk about displaying it in textview @0X0nosugar
    – user10238140
    Nov 11 at 15:04










  • Do you know how to display "Hello World" in a TextView?
    – 0X0nosugar
    Nov 11 at 15:05














  • 1




    Possible duplicate of Android SQLite Database : How to query for a specific data?
    – 0X0nosugar
    Nov 11 at 15:02










  • it doesn't talk about displaying it in textview @0X0nosugar
    – user10238140
    Nov 11 at 15:04










  • Do you know how to display "Hello World" in a TextView?
    – 0X0nosugar
    Nov 11 at 15:05








1




1




Possible duplicate of Android SQLite Database : How to query for a specific data?
– 0X0nosugar
Nov 11 at 15:02




Possible duplicate of Android SQLite Database : How to query for a specific data?
– 0X0nosugar
Nov 11 at 15:02












it doesn't talk about displaying it in textview @0X0nosugar
– user10238140
Nov 11 at 15:04




it doesn't talk about displaying it in textview @0X0nosugar
– user10238140
Nov 11 at 15:04












Do you know how to display "Hello World" in a TextView?
– 0X0nosugar
Nov 11 at 15:05




Do you know how to display "Hello World" in a TextView?
– 0X0nosugar
Nov 11 at 15:05












2 Answers
2






active

oldest

votes

















up vote
0
down vote













try this



for (UserDataHelper user:getData())
{

textView.append(user.getID()+" "+user.getName()
+" "+user.getRecieved()+" "+user.getSent()
+" "+user.getTimeSpent()+" "+user.getTotal()+"n");
}





share|improve this answer




























    up vote
    0
    down vote













    You could simply use the class object to set/get values, do following for string values:-



    textView.setText(quest.getName());


    and for the integer values make sure to use one

    of the following:-



    textView.setText(""+quest.getId());


    or



    textView.setText(String.valueOf(integer));





    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',
      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%2f53249972%2fdisplay-data-in-textview%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown
























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      try this



      for (UserDataHelper user:getData())
      {

      textView.append(user.getID()+" "+user.getName()
      +" "+user.getRecieved()+" "+user.getSent()
      +" "+user.getTimeSpent()+" "+user.getTotal()+"n");
      }





      share|improve this answer

























        up vote
        0
        down vote













        try this



        for (UserDataHelper user:getData())
        {

        textView.append(user.getID()+" "+user.getName()
        +" "+user.getRecieved()+" "+user.getSent()
        +" "+user.getTimeSpent()+" "+user.getTotal()+"n");
        }





        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          try this



          for (UserDataHelper user:getData())
          {

          textView.append(user.getID()+" "+user.getName()
          +" "+user.getRecieved()+" "+user.getSent()
          +" "+user.getTimeSpent()+" "+user.getTotal()+"n");
          }





          share|improve this answer












          try this



          for (UserDataHelper user:getData())
          {

          textView.append(user.getID()+" "+user.getName()
          +" "+user.getRecieved()+" "+user.getSent()
          +" "+user.getTimeSpent()+" "+user.getTotal()+"n");
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 16:05









          Dhanushka Dayawansha

          31119




          31119
























              up vote
              0
              down vote













              You could simply use the class object to set/get values, do following for string values:-



              textView.setText(quest.getName());


              and for the integer values make sure to use one

              of the following:-



              textView.setText(""+quest.getId());


              or



              textView.setText(String.valueOf(integer));





              share|improve this answer

























                up vote
                0
                down vote













                You could simply use the class object to set/get values, do following for string values:-



                textView.setText(quest.getName());


                and for the integer values make sure to use one

                of the following:-



                textView.setText(""+quest.getId());


                or



                textView.setText(String.valueOf(integer));





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  You could simply use the class object to set/get values, do following for string values:-



                  textView.setText(quest.getName());


                  and for the integer values make sure to use one

                  of the following:-



                  textView.setText(""+quest.getId());


                  or



                  textView.setText(String.valueOf(integer));





                  share|improve this answer












                  You could simply use the class object to set/get values, do following for string values:-



                  textView.setText(quest.getName());


                  and for the integer values make sure to use one

                  of the following:-



                  textView.setText(""+quest.getId());


                  or



                  textView.setText(String.valueOf(integer));






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 11 at 16:27









                  Kaveri

                  34938




                  34938






























                      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.





                      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%2fstackoverflow.com%2fquestions%2f53249972%2fdisplay-data-in-textview%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

                      Florida Star v. B. J. F.

                      Danny Elfman

                      Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues