inflate을 찾은 후에 루트보기의 의미를 이해하는 것이 어려워졌습니다. 이 생성 된 xml 계층 구조의 부모 뷰 또는 전체 뷰 계층 구조의 uppest 뷰 일뿐입니다.
LayoutInflater의 inflate 메소드를 사용할 때 Root View를 설정하는 방법은 무엇입니까?
나는 대답이 아마 전이라고 생각한다. 그러나 나는 문제에 직면하고있다. 경우 생성 된 계층 구조의 부모보기를 얻을 수없는 경우, 레이아웃 매개 변수를 설정할 때마다 계층 구조 트리를 부 풀릴 필요가 있습니까?
여기 내 코드입니다. 그리고 LinearLayout은 부모를 채울 수 없습니다. LinearLayout의 layout_height
및 layout_width
은 wrap_content
으로 설정되어야한다고 생각합니다. 자바 파일에서
storage_status.xml
<?xml version="1.0" encoding="utf-8"?>
<com.android.contacts.StorageStatusView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<View
android:layout_height="50px"
android:layout_width="50px"
android:background="#f00"/>
</com.android.contacts.StorageStatusView>
조각.
private class QuickActionClickListener implements QuickAction.OnActionItemClickListener {
@Override
public void onItemClick(QuickAction source, int pos, int actionId) {
switch (actionId) {
case ACTION_ID_STORAGE_STATUS :
final LayoutInflater inflater = getLayoutInflater();
new AlertDialog.Builder(ContactsListActivity.this)
.setTitle(UIUtils.getString(ContactsListActivity.this, R.string.storage_status))
.setView(inflater.inflate(R.layout.storage_status, null))
.show();
break;
}
}
}
미리 감사드립니다. 그리고 나의 가난한 영어를 유감스럽게 생각한다.
나는 누군가가 전에이 질문을 한 것을 발견했다. 그리고 대답은 분명히 끝납니다. http://stackoverflow.com/questions/5026926/making-sense-of-layoutinflater –