2012-03-09 78 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