RTF编辑器无法解析符号“编辑器”

时间:2016-11-28 09:33:31

标签: java android editor rtf

我是Android上的初学者。我想检查一下这个库是如何工作的。我想检查一下我自己项目中的一种可能性,但是有一个问题 - 我不知道如何声明变量“editor”和“预览”

MainActivity代码:

public class MainActivity extends AppCompatActivity {

private RichEditor mEditor;
private TextView mPreview;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mEditor = (RichEditor) findViewById(R.id.editor);
    mEditor.setEditorHeight(100);
    mEditor.setEditorFontSize(12);
    mEditor.setPadding(10, 10, 10, 10);
    mEditor.setPlaceholder("Insert text here...");

    mPreview = (TextView) findViewById(R.id.preview);

    mEditor.setOnTextChangeListener(new RichEditor.OnTextChangeListener() {
        @Override public void onTextChange(String text) {
            mPreview.setText(text);
        }
    });
    RichEditor editor = (RichEditor) findViewById(R.id.editor);

    editor.setOnTextChangeListener(new RichEditor.OnTextChangeListener() {
        @Override
        public void onTextChange(String text) {
            // Do Something
            Log.d("RichEditor", "Preview " + text);
        }
    });
    findViewById(R.id.action_bold).setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            mEditor.setBold();
        }
    });

}

0 个答案:

没有答案