Question

In my app I switch the view of two different graphs. The first time is the graph is drawn looks perfect, but when I go to the other one and come back looks like it draws two times the same graph but in different sizes and as soon as you click the graph it changes and looks perfect.

The screen when it looks wired is:

The screen when it looks wired is:

The code that draws the graph is always the same. This function is:

private void downloadInfo(String app, String object) {
    // Display flow graph
    //
    String query = "Select name from relation where obj_app = '" + app
            + "' and obj_name = '" + object
            + "' and obj_type = 1 and type= 22";
    String data = "name";
    String comparateur = new DataBaseAccess().execute(query, data);
    String compAux[] = comparateur.split("&");
    query = "Select * from data_1h where app = '" + app
            + "' and obj_name = '" + compAux[0] + "' and obj_type= 22";
    String file = new DataBaseAccess().execute(query, "file-date");
    String[] fileAux = file.split("&");
    date = fileAux[1];
    GraphicalView mChartView = new DebitGraph().execute(ShowGraph.this,
            fileAux[0], fileAux[1], compAux[0], object);
    RelativeLayout layout = (RelativeLayout) findViewById(R.id.graph1);
    layout.removeAllViews();
    Display display = getWindowManager().getDefaultDisplay();
    RelativeLayout.LayoutParams paramsForChart1 = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
//  paramsForChart1.bottomMargin = 25;
    layout.addView(mChartView, paramsForChart1);
    // Display Meteo graph
    query = "Select name from relation where obj_app = '" + app
            + "' and obj_name = '" + object
            + "' and obj_type = 1 and type= 20";
    data = "name";
    String station = new DataBaseAccess().execute(query, data);
    String stationAux[] = station.split("&");
    query = "Select * from data_1h where app = '" + app
            + "' and obj_name = '" + stationAux[0] + "' and obj_type= 20";
    data = "file-date";
    file = new DataBaseAccess().execute(query, data);
    fileAux = file.split("&");
    GraphicalView mChartView2 = new Meteo().execute(ShowGraph.this,
            fileAux[0], fileAux[1], stationAux[0], prec, temp);
    RelativeLayout.LayoutParams paramsForChart2 = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    layout = (RelativeLayout) findViewById(R.id.graph2);
    layout.removeAllViews();
//  paramsForChart2.bottomMargin = 25;
    layout.addView(mChartView2, paramsForChart2);

    // Display check boxes for temperature and precipitation
    RelativeLayout check = (RelativeLayout) findViewById(R.id.checks);
    check = (RelativeLayout) findViewById(R.id.checks);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout checkbox = (LinearLayout) inflater.inflate(
            R.layout.checkboxes, null);
    check.addView(checkbox);

    // Update text bar text with meteo info
    /*
     * TextView meteo = (TextView) findViewById(R.id.meteo);
     * meteo.setText("Méteo " + stationAux[0] + " " + fileAux[1]);
     * meteo.setTextColor(Color.BLACK); meteo.setTextSize(14);
     */
    if (MyDialog.isShowing()) {
        MyDialog.dismiss();
    }
}

I have alse changed the achartengine library as to change the zoom buttons but nothing else!

In my logCat I get this warning each time the screen goes crazy:

03-13 12:01:16.767: W/InputManagerService(229): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b1fb958

I've been looking this error in the forum but any of the answers I've found are usefull!

For more info, looks like I have the same problem as this post:

Achartengine: graph redraw on top of normal graph

But when I comment my onResume() the problem don't disappear!

Any ideas? Thanks!

Was it helpful?

Solution

When you return to the chart view, you may need to call a repaint() on it.

Another way to avoid such screen artifacts would be to call renderer.setInScroll(true);

Dan

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top