据我所知,有两种方法可以处理不同列表项上的点击:
setTag()到集类型在适配器列表中的项目,然后setOnItemClickListener()在列表getTag()视图的区分类型,如下所示:listview.setOnItemClickListener(new OnItemClcikListener(){});
setOnClickListener()在 期间单独为每个项目getView(),像这样:item.setOnClickListener(new OnClickListener() {});
有什么区别,哪个更受欢迎?
当我试图解决一个问题时
brew uninstall gcc
Run Code Online (Sandbox Code Playgroud)
我收到错误
No such keg: /usr/local/Cellar/gcc
Run Code Online (Sandbox Code Playgroud)
但实际上我已经安装了 gcc
which gcc
/usr/bin/gcc
Run Code Online (Sandbox Code Playgroud)
看起来brew 指向的是空的地方。即我也安装了 python/usr/bin/但brew info python显示了Not installed.
我该如何解决这个问题以将所有这些工具链接到brew?谢谢
这是#234 Leetcode问题:
给定一个单链表,确定它是否是回文。
跟进:您能在O(n)时间和O(1)空间中做到吗?
O(n)空间很容易解决这个问题。但是,我不知道O(1)解决方案。我想到的唯一方法是使用递归:
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
current = None
def isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
if not head or not head.next:
return True
self.current = head
return self.compare(head)
def compare(self, head):
if not head: return True
if not self.compare(head.next): return False
if head.val != self.current.val:
return False
else:
self.current = self.current.next
return True
Run Code Online (Sandbox Code Playgroud)
这适用于小样本,但给出
超过最大递归深度 …
python ×2
algorithm ×1
android ×1
homebrew ×1
linked-list ×1
listview ×1
macos ×1
palindrome ×1