如果我使用带有选择器的ImageButton作为其背景,是否有一种状态我可以改变它会改变它的外观?现在我可以让它在按下时更改图像,但似乎没有"突出显示"或"选中"或类似状态,这让我可以随意切换其外观.
这是我的XML; 它只会在按下时改变外观.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/map_toolbar_details_selected" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/map_toolbar_details_selected" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/map_toolbar_details_selected" />
<item android:drawable="@drawable/map_toolbar_details" />
Run Code Online (Sandbox Code Playgroud)
这种或那种方式有任何性能上的好处吗?它是编译器/ VM特定的吗?我正在使用Hotspot.
我有ListView自定义行.单击任何这些行时,将重新生成ListView的数据.当发生这种情况时,我希望列表回滚到顶部.
I initially tried using setSelection(0) in each row's OnClickListener
to achieve this but was unsuccessful (I believe because the ListView
loses its scroll position when its data is invalidated - so my call to
setSelection is undone. I still don't understand how the ListView
decides where to scroll to after invalidation, though).
The only working solution I know of was given by Romain Guy here: http://groups.google.com/group/android-developers/browse_thread/thread/127ca57414035301
It involves (View.post)ing the call to _listView.setSelection(0). I …
假设我有两个链接的表(一个具有另一个的外键):
CREATE TABLE Document (
Id INT PRIMARY KEY,
Name VARCHAR 255
)
CREATE TABLE DocumentStats (
Id INT PRIMARY KEY,
DocumentId INT, -- this is a foreign key to table Document
NbViews INT
)
Run Code Online (Sandbox Code Playgroud)
我知道,这不是最聪明的做事方式,但这是我能想到的最好的例子.
现在,我想获得拥有超过500个视图的所有文档.我想到的两个解决方案是:
SELECT *
FROM Document, DocumentStats
WHERE DocumentStats.Id = Document.Id
AND DocumentStats.NbViews > 500
Run Code Online (Sandbox Code Playgroud)
要么 :
SELECT *
FROM Document
INNER JOIN DocumentStats
ON Document.Id = DocumentStats.Id
WHERE DocumentStats.NbViews > 500
Run Code Online (Sandbox Code Playgroud)
两个查询都是等价的,还是有一种方法比另一种更好?如果是这样,为什么?
我知道我的例子并不完美,而且查询可能需要一些调整,但我希望你明白这一点;)!
编辑:根据答案中的要求,这个问题针对MSSQL,但我有兴趣知道它是否与其他数据库引擎不同(MySQL等...)
在生产模式下登录Android应用程序的最佳做法是什么,请记住以下要求:
能够上传日志以进行调试
能够清理日志或设置翻转
谢谢
很简单.这三者有什么区别?
我想列出设备中的每个图像.我应该使用managedQuery(),android.provider.MediaStore.Images.Media.query()还是context.getContentResolver.query()
我有一个返回List的方法,让我们调用它GetSomeStrings().
我在字符串类上有一个扩展方法,返回字符串中的字符数,例如.myString.Number('A').
我想在一行中抓一本字典.字典的条目包含字符串,以及字符串中所选字符的编号.
其实我做了以下事情:
var myDic = GetSomeStrings().ToDictionary(x=>x.Number('A'));
Run Code Online (Sandbox Code Playgroud)
这给了我一本字典<int,string>; 我希望密钥作为字符串.
之后,我想在int值上订购字典.可以在之前的声明中包含这个吗?
我真的想避免使用集合枚举来从列表中排序或创建字典,这实际上没有麻烦.感谢您的优化帮助!
我需要部署 GCP 计算实例列表。我如何通过像这样的对象列表中的“vms”循环 for_each:
"gcp_zone": "us-central1-a",
"image_name": "centos-cloud/centos-7",
"vms": [
{
"hostname": "test1-srfe",
"cpu": 1,
"ram": 4,
"hdd": 15,
"log_drive": 300,
"template": "Template-New",
"service_types": [
"sql",
"db01",
"db02"
]
},
{
"hostname": "test1-second",
"cpu": 1,
"ram": 4,
"hdd": 15,
"template": "APPs-Template",
"service_types": [
"configs"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)