小编Asi*_*LAN的帖子

如何更改弹出项目的宽度大小?

我使用自定义项目的弹出菜单.这样的问题

红线表示默认宽度大小.

在此输入图像描述

但我想要自定义较小宽度的项目(代表红线).

在此输入图像描述

     public void onClick(View v) {  
      //Creating the instance of PopupMenu  
      PopupMenu popup = new PopupMenu(MainLayout.this, mSikBtn);  
      popup.getMenuInflater().inflate(R.menu.poupup_menu, popup.getMenu());
      popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {  
       public boolean onMenuItemClick(MenuItem item) {  
        ...

        return true;  
       }  
      });  

      popup.show();//showing popup menu  
     }  
    });
Run Code Online (Sandbox Code Playgroud)

布局xml文件

<ImageView
        android:id="@+id/popupBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent" 
        android:src="@drawable/selector_sik"
        android:layout_weight="1"
        android:layout_margin="10dip"
        />
Run Code Online (Sandbox Code Playgroud)

popup_menu.xml文件

 <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item  
        android:id="@+id/one"  
        android:title="A)."/>  
      ...

    <item  
        android:id="@+id/three"  
        android:title="E)."/>  

</menu>
Run Code Online (Sandbox Code Playgroud)

类似的问题:stackoverflow.com 我需要自定义弹出菜单

xml android

7
推荐指数
1
解决办法
2万
查看次数

如何修复“错误:无法构建 gem 本机扩展。” 安装cocoapods时出错?

我正在尝试在全新的 Mac OS X 11.1 上安装 cocoapods。我已经运行了这些命令:

sudo gem install cocoapods -n /usr/local/bin
Run Code Online (Sandbox Code Playgroud)

但是,当我运行最后一个命令时,出现此错误:

ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20201226-10485-158gl5m.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.14.2/gem_make.out

Run Code Online (Sandbox Code Playgroud)

我怎么做?

ruby cocoapods

6
推荐指数
1
解决办法
2万
查看次数

SwiftUI:如何在水平滚动视图中监听鼠标滚轮滚动事件

我正在开发一个 macos 软件,我发现在 swiftui 中,滚动视图设置为.horizontal,因此当鼠标滚轮滚动时列表不会滚动,但在.vertical模式下会滚动。

但我确实需要这个功能。

所以我尝试了一种选择:实现一个可以处理鼠标滚轮滚动事件的NSViewRepresentableNSView 重写方法。scrollWheel然后发布通知。

struct MouseWheelScrollEventView : NSViewRepresentable {
    
    class MouseView : NSView {
        override var acceptsFirstResponder: Bool {
            true
        }
        
        override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
            return true
        }
                
        override func scrollWheel(with event: NSEvent) {
            NotificationCenter.default.post(name: Notification.Name("mouseevent"), object: event)
        }
    }
    
    
    func makeNSView(context: Context) -> some NSView {
        let view = MouseView()
        
        DispatchQueue.main.async {
            view.window?.makeFirstResponder(view)
        }
        return view
    }
    
    func updateNSView(_ nsView: NSViewType, context: Context) …
Run Code Online (Sandbox Code Playgroud)

macos xcode swiftui

4
推荐指数
1
解决办法
2591
查看次数

SwiftUI 解码 HTML 实体错误:同时访问 0x7ff43ff29b50,但修改需要独占访问

当我使用 解码 html entites 时出现错误NSAttributedString。我使用 Swift 5。我只想将 html 字符串化。我不想要网络视图。

SwiftUI 文本

Text("It&#39s a party!".decoded)
Run Code Online (Sandbox Code Playgroud)

字符串扩展

extension String {
    var decoded: String {
        let attr = try? NSAttributedString(data: Data(utf8), options: [
        .documentType: NSAttributedString.DocumentType.html,
        .characterEncoding: String.Encoding.utf8.rawValue
    ], documentAttributes: nil)

        return attr?.string ?? self
    }
}
Run Code Online (Sandbox Code Playgroud)

错误日志

== AttributeGraph: cycle detected through attribute 123464 ===
=== AttributeGraph: cycle detected through attribute 143224 ===
=== AttributeGraph: cycle detected through attribute 128744 ===
Simultaneous accesses to 0x7ff43ff29b50, but modification requires exclusive access.
Previous …
Run Code Online (Sandbox Code Playgroud)

decode swiftui

4
推荐指数
1
解决办法
1080
查看次数

当我使用命令行进行屏幕录制时,为什么屏幕录制会出错

我试图按照这篇文章对我的Android设备进行屏幕录制,但是我收到以下错误:

adb shell screenrecord /sdcard/demo.mp4
/system/bin/sh: screenrecord: not found
Run Code Online (Sandbox Code Playgroud)

我的Android设备运行的是4.1.2版.

android adb screen-recording

3
推荐指数
1
解决办法
6075
查看次数

标签 统计

android ×2

swiftui ×2

adb ×1

cocoapods ×1

decode ×1

macos ×1

ruby ×1

screen-recording ×1

xcode ×1

xml ×1