문제

Suppose I have a simple layout xml like the following:

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" />

Are there any differences in the following calls? and which one should i use?

button = (Button) getLayoutInflater().inflate(R.layout.button, null);

and

View v = getLayoutInflater().inflate(R.layout.button, null);
button = (Button) v.findViewById(R.id.button01);

올바른 솔루션이 없습니다

다른 팁

문서 라이브러리에서 파일의 체크 아웃 상태를 확인하는 방법

파일을 검색하는 다음 방법

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;
      }
}
.

파일의 체크 아웃 상태를 확인하려면 ( CheckOuttype )

var listItem = GetListItem("https://contoso.sharepoint.com", credentials, "Documents", 1);
 var file = listItem.File;
 if (file.CheckOutType !=  CheckOutType.None)
 {
        //file was checked out
 }  
.


체크 아웃 상태를 확인하는 방법 ( SPFile) .>ssom 를 사용하는 문서 라이브러리의 파일의 spcheckoutstatus )
SPFile file = item.File;
if (file.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
    //file was checked out
}
.

The first option is cleaner and slightly more efficient.

Your layout inflater will return a Button. With the first option, you gain access to the Button directly. With the second option, you cast the button down to a View and then look for the view with a given ID, which is an extra useless comparison, since the view with the ID you're looking for in the hierarchy happens to be the button itself. So in the second option, v == button.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top