After i looking up inflate, i found it quit hard to understand what does the root view mean. Is it just the parent view of this generated xml hierarchy or the uppest view of the whole view hierarchy.
I think the answer most probably be the former. But I am facing a problem. If in the case that i can't get the parent view of this generated hierarchy, do i have to set the layout parameter everytime i inflate a hierarchy tree?
Here is my code. And the LinearLayout can't fill the parent. I think the layout_height
and layout_width
of the LinearLayout must be set to 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>
Snippets in java file.
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;
}
}
}
Thanks in advance. And sorry for my poor english.