2012-03-09 49 views
1

在我的应用程序中,我切换了两个不同图形的视图。第一次是绘制的图表看起来很完美,但是当我去到另一个并且回来看起来像它绘制了两次同样的图形,但是大小不同,并且一旦你点击图形,它就会改变并且看起来很完美。Achartengine:在正常图形上重绘图

的画面时,它看起来是有线:

The screen when it looks wired 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(); 
    } 
} 

我已经改变了achartengine库改变缩放按钮,但没有别的!

在我的logcat我得到这个每次警告屏幕发疯:

03-13 12:01:16.767: W/InputManagerService(229): Window already focused, ignoring focus gain of: [email protected] 

我一直在寻找这个错误的论坛,但任何我找到的答案是有用的!

欲了解更多信息,貌似我也有同样的问题,因为这个帖子:

Achartengine: graph redraw on top of normal graph

但是,当我的评论我的onResume()问题不会消失!

任何想法? 谢谢!

+0

我们有任何例如对于这一个... – NagarjunaReddy 2014-03-06 14:25:07

回答

2

当您返回到图表视图时,您可能需要调用repaint()。

另一种避免这种屏幕伪影的方法是调用renderer.setInScroll(true);

+0

OK,它没有工作“在开始时看起来像,但错误只是转移到另一个地方!我会编辑与更多信息的问题我有! – Lucia 2012-03-13 11:03:22

+0

请看看我上面编辑的答案 – 2012-03-13 15:30:12

+0

我不能感谢你enouth !!只是在提供应用程序的几天之内就让我疯狂!!谢谢你这么多!! – Lucia 2012-03-13 15:35:22