使用TextWatcher将文本用作图形数据

时间:2017-03-23 15:57:51

标签: android android-textwatcher

我正在创建一个脉搏率监控应用。脉冲率以实时变化的文本显示。我想将脉搏率显示为图表。如何使用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;
}

0 个答案:

没有答案