题
假设我有一个简单的布局XML,如以下内容:
button.xml:
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
以下电话有什么区别吗?我应该使用哪一个?
button = (Button) getLayoutInflater().inflate(R.layout.button, null);
和
View v = getLayoutInflater().inflate(R.layout.button, null);
button = (Button) v.findViewById(R.id.button01);
没有正确的解决方案
其他提示
如何使用CSOM 验证文档库中文件的签出状态
假设以下方法检索文件
private static ListItem GetListItem(string url, ICredentials creds, string listTitle,int listItemId)
{
using (var clientContext = new ClientContext(url))
{
clientContext.Credentials = creds;
var list = clientContext.Web.Lists.GetByTitle(listTitle);
var listItem = list.GetItemById(listItemId);
clientContext.Load(list);
clientContext.Load(listItem,i => i.File);
clientContext.ExecuteQuery();
return listItem;
}
}
.
然后验证文件的结帐状态(
第一个选择是更清洁的,效率更高。
您的布局膨胀者将返回 Button
. 。使用第一个选项,您可以访问 Button
直接地。使用第二个选项,您将按钮放到 View
然后查找具有给定ID的视图,这是一个毫无用处的比较,因为您在层次结构中寻找的ID的视图恰好是按钮本身。因此,在第二个选项中, v == button
.
不隶属于 StackOverflow