Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5991153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:20:47+00:00 2026-05-22T23:20:47+00:00

I’m using a chart taken from here http://writerbay.wordpress.com/2011/03/12/android-tutorial-displaying-chart-on-android/#comment-54 to draw a graph in android.

  • 0

I’m using a chart taken from here
http://writerbay.wordpress.com/2011/03/12/android-tutorial-displaying-chart-on-android/#comment-54

to draw a graph in android.
The data used for drawing the graph is taken from a DB.
On x axis I put the data and on the y-axis I put some numbers meaning the speed.

The data from DB is readed using Async thread.

What I wanna do is the following:

*read four values for data and four values for speed and put them on the chart

*reading the following four values and update my chart….until the data from the DB is readed

The problem I’m facing is that:

LineView lv; my chart has a constructor that accepts as parameters only arrays[]

So I have to pass it the array containing the whole data….which is against what I want to do.

public class InitTask extends AsyncTask<DBAdapter,String, Void> {

    String TABLE_3;

    protected Void doInBackground(DBAdapter... db) {
        try {
            db[0].createDatabase();
            db[0].openDataBase();
            Cursor c = db[0].getCursor3(db[0].TABLE_3, user_id);


            viteza = new float[4];
            time = new String[4];

            if (c.moveToFirst()) {

                do {
                    int a=(int)Double.parseDouble(c.getString(3));

                    publishProgress(Integer.toString(a),c.getString(4));
                    Thread.sleep(500);


                } while (c.moveToNext());

            }
            c.close();
            db[0].close();

        } catch (Exception e) {
            Log.d("Eroare", "doInBackground", e);
        }

        return null;
    }

    protected void onProgressUpdate(String...values) {

        Aitem items[] = new Aitem[1];

      viteza[contor]=Float.parseFloat(values[0]);

     time[contor]=values[1];


        items[0]=new Aitem(Color.RED, "Evolution",viteza);


        lv.setAxisValueX(time);

    lv.setItems(items);


        setContentView(lv);
        }

}

time is an array-containing my data which I put on the x-axis it must be a String

viteza-is for speed and is also an array which contains float numbers.

This is how I obtaing the graph:

items[0]=new Aitem(Color.RED, “Evolution”,viteza);

lv.setItems(items);

The problem is that the Aitem() constructor needs arrays[] String as parameters….and I cannot find a way to update that array[] with the new values(four vnew values step by step)

forgetting about the old ones..

So at an moment in time only four values are displayed on my graph….

The problem is that I don’t know how to do that…

Has anyone any clue of how could I do that…Thank u!

EDIT:initial value for contor=0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:20:47+00:00Added an answer on May 22, 2026 at 11:20 pm

    You have two options that I can see. The first would be easier to implement but harder on performance and that is to wife the display and draw the graph all over again reading in as many as you want. The second option would be to read in 4 points and draw those and then read in the next 4 and draw those in a new line and so on.

    -= EDIT =-

    public class InitTask extends AsyncTask<DBAdapter, Double, Void> 
    {
        String TABLE_3;
    
        protected Void doInBackground(DBAdapter... db)
        {
            try
            {
    
                // Like before
    
                do
                {
                    double x1 = Double.parseDouble(c.getString(1));
                    double y1 = Double.parseDouble(c.getString(2));
                    double x2 = Double.parseDouble(c.getString(3));
                    double y2 = Double.parseDouble(c.getString(4));
                    double x3 = Double.parseDouble(c.getString(5));
                    double y3 = Double.parseDouble(c.getString(6));
                    double x4 = Double.parseDouble(c.getString(7));
                    double y4 = Double.parseDouble(c.getString(8));
    
                    publishProgress(x1, y1, x2, y2, x3, y3, x4, y4);
                    Thread.sleep(500);
                } while (c.moveToNext());
    
                // Like before
    
                return;
        }
    
    protected void onProgressUpdate(Double...values)
    {
        double x1 = values[0];
        double y1 = values[1];
        double x2 = values[2];
        double y2 = values[3];
        double x3 = values[4];
        double y3 = values[5];
        double x4 = values[6];
        double y4 = values[7];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.