【问题标题】:How to remove toolbar buttons in dankito/RichTextEditor for Android如何删除 dankito/RichTextEditor for Android 中的工具栏按钮
【发布时间】:2018-09-01 10:20:47
【问题描述】:

我成功地将以下库集成到我的 Android 应用项目中。效果很好,感谢作者dankito

RichTextEditor

但是,我想从工具栏中删除一些按钮。 (标题 1 - 6,正文,预格式化,块引用,插入复选框..)

但我不明白该怎么做。它是用 Kotlin 编写的。

是否可以简单地做到这一点?我被卡住了……

我还想更改字符串以将它们翻译成法语。有可能吗?

这是我显然无法修改的库代码。

package net.dankito.richtexteditor.android.toolbar

import android.content.Context
import android.util.AttributeSet
import net.dankito.richtexteditor.android.command.*


class AllCommandsEditorToolbar : EditorToolbar {

    constructor(context: Context) : super(context) { initToolbar() }
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { initToolbar() }
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initToolbar() }
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { initToolbar() }



    private fun initToolbar() {
        addCommand(BoldCommand())
        addCommand(ItalicCommand())
        addCommand(UnderlineCommand())
        addCommand(StrikeThroughCommand())
        addCommand(SuperscriptCommand())
        addCommand(SubscriptCommand())
        addCommand(RemoveFormatCommand())

        addCommand(UndoCommand())
        addCommand(RedoCommand())

        addCommand(BlockQuoteCommand())
        addCommand(SetTextFormatCommand())
        addCommand(SetFontNameCommand())
        addCommand(SetFontSizeCommand())
        addCommand(SwitchTextColorOnOffCommand())
        addCommand(SetTextColorCommand())
        addCommand(SwitchTextBackgroundColorOnOffCommand())
        addCommand(SetTextBackgroundColorCommand())

        addCommand(DecreaseIndentCommand())
        addCommand(IncreaseIndentCommand())

        addCommand(AlignLeftCommand())
        addCommand(AlignCenterCommand())
        addCommand(AlignRightCommand())
        addCommand(AlignJustifyCommand())

        addCommand(InsertBulletListCommand())
        addCommand(InsertNumberedListCommand())

        addCommand(InsertLinkCommand())
        addCommand(InsertImageCommand())
        addCommand(InsertCheckboxCommand())

        addSearchView()
    }

}

感谢您的帮助

【问题讨论】:

    标签: java android kotlin github-pages rich-text-editor


    【解决方案1】:

    为了修改库,您需要从Build.gradle删除当前库的依赖项 ,然后,在 Android Studio 中添加库作为模块

    This answer 已经解释了如何做到这一点。

    关于您对库的修改,在initToolbar 方法(或其他方法,取决于库的实现)中,您需要删除Button(或任何您想要的)以及库中的相关代码.

    即:Remove : addCommand(UndoCommand()) 从库中删除 UndoCommand 然后在库中查找相关代码并将它们也删除。

    【讨论】:

      猜你喜欢
      • 2017-03-08
      • 2019-09-10
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 2019-07-31
      • 1970-01-01
      • 2017-05-06
      相关资源
      最近更新 更多