小编Moh*_*lah的帖子

android - 禁用Listview项目单击并重新启用它

所以我在适配器中有以下代码:

@Override
    public boolean isEnabled(int position) 
    {
         GeneralItem item = super.getItem(position);
         boolean retVal = true;


            if (item != null)
            {
                if (currSection != some_condition)
                retVal = !(item.shouldBeDisabled());
            }
         return retVal;
     }


    public boolean areAllItemsEnabled() 
    {
        return false;
    }
Run Code Online (Sandbox Code Playgroud)

这里的问题是:如果我在初始绑定期间禁用了我的项目,现在我在屏幕上引发事件并且无论如何都需要启用它们.在执行该操作后,我是否再次重新绑定它?

例如:

onCreate{

// create and bind to adapter
// this will disable items at certain positions 

}

onSomeClick{

I need the same listview with same items available for click no matter what the conditions of positions are, so I need them …
Run Code Online (Sandbox Code Playgroud)

android listview adapter

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

使用特定采样率捕获音频样本,如 iOS Swift 中的 Android

我是在 IOS 中使用声音和 AVAudioEngine 的初学者,我正在开发一个应用程序,将音频样本捕获为缓冲区并对其进行分析。此外,采样率必须为 8000 kHz,也必须编码为 PCM16Bit,但 AVAudioEngine 中的默认 inputNode 为 44.1 kHz。

在 Android 中,过程非常简单:

AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
                8000, AudioFormat.CHANNEL_IN_MONO,
                AudioFormat.ENCODING_PCM_16BIT, bufferSize);
Run Code Online (Sandbox Code Playgroud)

然后启动缓冲区的读取功能。我搜索了很多,但没有找到任何类似的例子。相反,我遇到的所有示例都以默认节点的采样率(44.1 kHz)捕获样本,例如:

    let input = audioEngine.inputNode
    let inputFormat = input.inputFormat(forBus: 0)
    input.installTap(onBus: 0, bufferSize: 640, format: inputFormat) { (buffer, time) -> Void in
                print(inputFormat)
                if let channel1Buffer = buffer.floatChannelData?[0] {
                    for i in 0...Int(buffer.frameLength-1) {
                        print(channel1Buffer[i])
                    }
                }
            }
try! audioEngine.start()
Run Code Online (Sandbox Code Playgroud)

所以我想使用 AVAudioEngine 以 8000 kHz 采样率和 PCM16Bit 编码捕获音频样本。

*编辑: 我找到了将输入转换为 8 kHz 的解决方案: …

pcm avfoundation ios swift avaudioengine

5
推荐指数
1
解决办法
929
查看次数

如何在Mapkit Swift中随意放置注释

我想知道如何在MapView中随机地固定15个注释

    let latitude: CLLocationDegrees = 33.606800
    let longitude: CLLocationDegrees = -111.845360
    let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)

    //map annotation
    let annotation = MKPointAnnotation()
    annotation.coordinate = location
    annotation.title = "Taliesin West"
    annotation.subtitle = "Design"
    map.addAnnotation(annotation) 
Run Code Online (Sandbox Code Playgroud)

xcode mapkit ios swift

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

标签 统计

ios ×2

swift ×2

adapter ×1

android ×1

avaudioengine ×1

avfoundation ×1

listview ×1

mapkit ×1

pcm ×1

xcode ×1