动态edittext当被破坏的android

时间:2014-10-13 22:41:12

标签: java android dynamic android-edittext

我正在为Android编写电子表格应用程序并获取单元格值我使用动态edittext。 这是否可以在写入文本时获取信息并将其保存为单元格值?

这是代码的一部分:

@Override
public boolean onTouchEvent(MotionEvent event){

    if(Selection != null) {
        Cell prevSelection = hostActivity.logic.getCell(Selection.left, Selection.top);
        SelTxt = hostActivity.txtInput.getText().toString();

        if(SelTxt.length() != 0 && prevSelection.GetValue() != SelTxt && prevSelection.getChanged()) {
            prevSelection.setValue(SelTxt);
            hostActivity.txtInput.clearComposingText();
            prevSelection.Modified(false);
            SelTxt = "";
        }
    }


    switch(event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
        int x = (int) event.getX();
        int y = (int) event.getY();

            calculateSelectionRect(x, y);
            SelectionChanged = true;

            if(x > startTableX && y > startTableY && !GroupSelected) {
                Cell tmpCell = hostActivity.logic.getCell(Selection.left, Selection.top);
                hostActivity.EditSelectedCellValue(Selection.left, Selection.top, Selection.right, Selection.bottom, tmpCell);
            }
        invalidate();

        if(txtInput != null)
        frameLayout.removeView(txtInput);

    String tmpText = "";
    txtInput = new EditText(this.getApplicationContext());

    FrameLayout.LayoutParams txtParams = new FrameLayout.LayoutParams((right - left), (bottom - top));
    txtInput.setX(left);
    txtInput.setY(top);
    txtInput.setText(value.GetValue());
    txtInput.setTextColor(R.color.Selected_Cell_Border);
    txtInput.setBackgroundColor(getResources().getColor(R.color.Selected_Cell));

    frameLayout.addView(txtInput, txtParams);
    setContentView(frameLayout);

    tmpText = txtInput.getText().toString();

    if(txtInput.getText().toString() != value.GetValue())
        value.Modified(true);

    txtInput.clearComposingText();
    return tmpText;
}

在应用程序中,它的工作方式是在填充一个单元格并直接选择单元格后面的值被复制一次,另一个选择此单元格给出好的空单元格并且没问题。但它很烦人,不应该发生

0 个答案:

没有答案