android - 与对话框中的 TextView 关联的复制/粘贴操作栏上未显示的按钮

标签 android android-actionbar textview

遗憾的是,我只能在搭载 Android 4.1.2 的三星 N7000 Note 手机上进行测试,因为它是我唯一的设备。我的应用程序建立了一个如下构造的对话框:

AlertDialog.Builder alert = new AlertDialog.Builder(this);

// Set an TextView view to get user input
final TextView input = new TextView(this);
input.setTextIsSelectable(true);
input.setText(sb.toString());
alert.setView(input);
alert.setTitle("Title");
alert.setPositiveButton(getString(R.string.ok),
    new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface dialog, int whichButton)
      {
        // do something here
      }
    });

alert.show();

这会按预期打开对话框。然而,如此处所示,attached screen shot当我尝试选择 TextView 中显示的文本时,会显示复制/粘贴操作栏,但操作栏中不会显示用于复制、全选等的按钮。我注意到我可以触摸右上角,短暂地看到一个按钮,然后看到一条消息说已复制到剪贴板。然后我可以去别处粘贴数据。所以功能就在那里,只是没有向用户显示。

任何人都可以阐明我在这里做错了什么吗?

谢谢

最佳答案

您是否偶然使用了 ActionbarSherlock?貌似是框架的bug,解决方法是重新手动设置主题,最好在onCreateDialog方法中。

看到这个: Invisible ActionMode item icons


Invisible Actionbar Buttons

关于android - 与对话框中的 TextView 关联的复制/粘贴操作栏上未显示的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25684940/

相关文章:

android - 使用 Scala 插件在 Android Studio 中设置测试

android - 在 Android Studio 上为增强的 GeofencingApi 轮询 GPS 位置的正确程序

android - 首选项菜单中 Android 向上/向后导航的动态父 Activity

java - 线程(textView 和进度条)

android - 我可以在使用 LinkMovementMethod 时禁用 TextView 中的滚动吗?

安卓 ICS : Default browser not respecting <meta> viewport tags

android - 如何在 Fresco 库中将 DraweeView 的尺寸设置为 "wrap_content"

android - 使用 ActionBarSherlock Menus 在新的 4.0 及更高版本上显示旧菜单按钮 - 包含图片

android - 如何在运行时添加操作栏项

android - 如何确定 TextView 中是否触摸了链接或纯文本