このタッチイベントを取得してCSVに書き込むプログラムでログ出力されている部分を文字列に変えたいのですがどのようにすればよろしいか教えてください。
package com.example.admin.tatchme;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import java.io.PrintWriter;
import android.view.MotionEvent;
import android.view.View;
import java.io.*;
public class tatchme extends Activity {
long num = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tatchme); } public void insert(View view) { String filePath = Environment.getExternalStorageDirectory() + "/102.csv"; File file = new File(filePath); file.getParentFile().mkdir(); FileOutputStream fis = null; BufferedWriter PrintWriter = null; try { fis = new FileOutputStream(file, true); PrintWriter = new BufferedWriter(new OutputStreamWriter(fis)); PrintWriter.newLine(); PrintWriter.write("保存"); PrintWriter.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (PrintWriter != null) { try { PrintWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
// return false;
}
}
@Override public boolean onTouchEvent(MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: Log.d("","EventLocation X:"+(int)motionEvent.getX()); Log.d("", "EventLocation Y:" + (int) motionEvent.getY()); Log.d("", "p" + num + ": " + motionEvent.getDownTime()); Log.d("", "Press" + num + ": " + (double) motionEvent.getPressure()); break; case MotionEvent.ACTION_UP: Log.d("", "r" + num + ": " + motionEvent.getEventTime()); break; case MotionEvent.ACTION_MOVE: Log.d("", "ACTION_MOVE"); break; case MotionEvent.ACTION_CANCEL: Log.d("", "ACTION_CANCEL"); break;
//str+= namae+","
} String filePath = Environment.getExternalStorageDirectory() + "/102.csv"; File file = new File(filePath); file.getParentFile().mkdir(); FileOutputStream fis = null; BufferedWriter PrintWriter = null; try { fis = new FileOutputStream(file, true); PrintWriter = new BufferedWriter(new OutputStreamWriter(fis)); PrintWriter.newLine(); PrintWriter.write(motionEvent.getX() + "," + motionEvent.getY()+","+ motionEvent.getDownTime()+","+ motionEvent.getEventTime()+","+(double) motionEvent.getPressure()); PrintWriter.newLine(); PrintWriter.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (PrintWriter != null) { try { PrintWriter.close(); } catch (IOException e) { e.printStackTrace(); } } return false; } }
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/08 08:41
2017/01/08 08:48
2017/01/08 09:57
2017/01/08 13:10
2017/01/08 13:44 編集