나는 매우 새로운 Android 버전 &을 사용하고 있으며, 스스로 작성한 Android 앱을 배우려고합니다. CSV 파일에서 값을 읽고 그 값을 계획하려고 할 때 문제가 발생했습니다. 좀 더 구체적으로, 나는 Androidplot 예제를 수정하려고했습니다.csv 파일을 android에서 배열로 변환 할 수 없습니다.
원래 Androidplot 예제가 작동하지만 수정 된 코드는 작동하지 않습니다 ... 문제를 찾으려고했으나 실패했습니다. 실패했습니다 ... 코드를 디버그하려고 할 때마다 ActivityThread.java가 튀어 나오고
이catch (Exception e) {
if (!mInstrumentation.onException(activity, e)) {
throw new RuntimeException(
"Unable to start activity " + component
+ ": " + e.toString(), e);
}
}
이 사람이 문제가 정말 무엇인지 말해 줄 수 : 다음 코드에 약간 가리키는 화살표가있다? 어떤 도움이 많이
다음내 수정 된 코드입니다) = 이해 될 것이다 :
package edu.ius.rwisman.AndroidPlotExample;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
public class AndroidPlotExampleActivity extends Activity
{
private XYPlot mySimpleXYPlot;
@SuppressWarnings("null")
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Initialize our XYPlot reference:
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
Number[] series1Numbers = null;
Number[] series2Numbers = null;
int row = 0;
// Create two arrays of y-values to plot:
try {
File file = new File("/home/hanrui/workspace/table.csv");
BufferedReader reader = new BufferedReader(new FileReader(file));
reader.readLine();
String line = null;
while((line=reader.readLine())!=null&&row<24){
String item[] = line.split(",");
String last = item[item.length-1];
int value = Integer.parseInt(last);
series1Numbers[row] = value;
series2Numbers[row] = value;
row++;
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Turn the above arrays into XYSeries:
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numbers), // SimpleXYSeries takes a List so turn our array into a List
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
"Series1"); // Set the display title of the series
// Same as above, for series2
XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
"Series2");
// Create a formatter to use for drawing a series using LineAndPointRenderer:
LineAndPointFormatter series1Format = new LineAndPointFormatter(
Color.rgb(0, 200, 0), // line color
Color.rgb(0, 100, 0), // point color
Color.rgb(150, 190, 150)); // fill color (optional)
// Add series1 to the xyplot:
mySimpleXYPlot.addSeries(series1, series1Format);
// Same as above, with series2:
mySimpleXYPlot.addSeries(series2, new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100),
Color.rgb(150, 150, 190)));
// Reduce the number of range labels
mySimpleXYPlot.setTicksPerRangeLabel(3);
// By default, AndroidPlot displays developer guides to aid in laying out your plot.
// To get rid of them call disableAllMarkup():
mySimpleXYPlot.disableAllMarkup();
}
}
당신이 안드로이드 개발을 위해 가지고 있어야하는 유틸리티 중에는 "adb.exe"라는 파일과 심지어 어떤 줄까지 문제의 어떤 종류의 예외를 정확하게 제공 할 로그를 보려면 "adb.exe logcat"을 실행하십시오 입니다! –
일반적으로 디버그 정보 (예 : LogCat의 디버그 정보)에는 예외가 발생한 소스 파일의 행 번호가 들어 있습니다. 그 라인을 알지 못하면 문제를 찾기가 어렵습니다. stacktrace를 찾아 여기에 게시하십시오. –
답장을 보내 주셔서 감사합니다. 아무 것도 없지만 LogCat을 확인했지만 DDMS에보고 된 오류가 있습니다 : - logcat을 시작하는 동안 예기치 않은 오류가 발생했습니다. 장치를 다시 선택하십시오] 장치는 com.android.ddmlib.AdbCommandRejectedException를 찾을 수 없습니다. 장치가 \t com.android.ddmlib.AdbHelper에서 com.android.ddmlib.AdbHelper.setDevice (AdbHelper.java:752)에서 \t를 찾을 수 없음 .executeRemoteCommand (AdbHelper.java:373) com.android.ddmlib.Device.executeShellCommand (Device.java:397)에서 \t com.android.ddmuilib.logcat.LogCatReceiver $ 1.run에서 \t (LogCatReceiver.java:102) \t at java.lang.Thread.run (Thread.java:636) –