我是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();
}
});
}