0

I am creating a Pulse rate monitoring app. The pulse rate is displayed in text which changes in realtime. I want to display the pulse rate as a graph. How can I graph from pulse rate from the text using TextWatcher?

    @Override
final public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View heartview = inflater.inflate(R.layout.fragment_heart, container, false);
    previewHolder = preview.getHolder();
    previewHolder.addCallback(surfaceCallback);
    previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    image = heartview.findViewById(R.id.image);
    text = (TextView)heartview.findViewById(R.id.text);

    PowerManager pm = (PowerManager)getActivity().getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");

    text.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

       // What to do here?

        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });


return heartview;
}
Abhi
  • 3,431
  • 1
  • 17
  • 35
  • Can you clarify the question ? You want some sinusoidal graph symbolizing the pulse rate from the editText, like 60/min ? – Feuby Mar 23 '17 at 16:13
  • It should be a simple line graph which changes on text. – Abhi Mar 23 '17 at 16:15
  • Maybe you should consider using a canvas to draw something https://developer.android.com/reference/android/graphics/Canvas.html – Feuby Mar 23 '17 at 16:21
  • @Feuby I have some pulse rate generated in a TextView which has to be plotted on a graph. I am not sure how to use a canvas to do this. Thanks – Abhi Mar 23 '17 at 16:33
  • Just do like in school. Basically a canvas is already a graph with coordinates. Calculate points and link them. The post is so unclear that i''m not even sure what do you want as curve. Sinusoid ? impulsions ? heart-shaped curves ? – Feuby Mar 23 '17 at 21:03

0 Answers0