AndroidAceEditor
1.0.0
這是用於集成作為整體UI的模塊化組件的文本/代碼編輯器。目的是提供一個強大的編輯器,可以像其他任何視圖一樣使用。
ACE文本編輯器已用於此目的,因為它具有功能豐富,快速且易於修改和嵌入應用程序。
請注意,目前在Android版本5.0(Lollipop)及以上支持此庫。
allprojects {
repositories {
.. .
maven {
url ' https://jitpack.io '
}
}
}dependencies {
.. .
compile ' com.github.Susmit-A:AndroidAceEditor:0.5.0 '
}...
< com .susmit.aceeditor.AceEditor
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : id = " @+id/editor " />
...演示活動:
public class MainActivity extends Activity {
@ Override
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState );
setContentView ( R . layout . activity_main );
editor = findViewById ( R . id . editor );
//call this to set up themes or modes at time of creation of view.
//If you are setting the theme or mode through another view's action,
//call setTheme and/or setMode directly
editor . setOnLoadedEditorListener ( new OnLoadedEditorListener () {
@ Override
public void onCreate () {
editor . setTheme ( AceEditor . Theme . TERMINAL );
editor . setMode ( AceEditor . Mode . C_Cpp );
}
});
//Since a WebView is used for the content, you need to set the following listener to process the text
//It is also used to retrive other values, such as selected text or number of lines
editor . setResultReceivedListener ( new ResultReceivedListener () {
@ Override
public void onReceived ( String text , int FLAG_VALUE ) {
if ( FLAG_VALUE == AceEditor . Request . VALUE_TEXT )
{
Toast . makeText ( MainActivity . this , "Typed text: n n " + text , Toast . LENGTH_SHORT ). show ();
}
}
});
}
}