gpt4 book ai didi

android - Achartengine:在法线图之上重新绘制图形

转载 作者:行者123 更新时间:2023-11-29 22:11:04 25 4
gpt4 key购买 nike

在我的应用程序中,我切换了两个不同图表的 View 。第一次绘制的图形看起来很完美,但是当我转到另一个图形并返回时,看起来它绘制了同一个图形的两次,但大小不同,一旦您单击图形,它就会改变并看起来很完美。

看起来有线时的屏幕是:

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: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b1fb958

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

有关更多信息,看起来我遇到了与这篇文章相同的问题:

Achartengine: graph redraw on top of normal graph

但是当我评论我的 onResume() 时,问题并没有消失!

有什么想法吗?谢谢!

最佳答案

当您返回到图 TableView 时,您可能需要对其调用 repaint()。

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

关于android - Achartengine:在法线图之上重新绘制图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9636991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com