사용자 지정보기 "RowWrapperView"다음과 같은 예를 들어 레이아웃을 감안할 때 :사용자 정의보기
(row_item.xml)
<?xml version="1.0" encoding="utf-8"?>
<com.example.android.RowWrapperView
xmlns:android="http://schemas.android.com/apk/res/android"
... >
<Button android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</com.example.android.RowWrapperView>
뷰가 비정상적으로 레이아웃을 가지고 (view_row_wrapper .XML) ID가 "R.id.container"와있는 LinearLayout과 :
public class RowWrapperView extends RelativeLayout {
public RowWrapperView(Context context) {
super(context);
init();
}
public RowWrapperView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public RowWrapperView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public LinearLayout container;
private void init() {
inflate(getContext(), R.layout.view_row_wrapper, this);
container = (LinearLayout) findViewById(R.id.container);
}
}
(view_row_wrapper.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
... >
<LinearLayout
android:id="@+id/something"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
...
</LinearLayout>
<LinearLayout
android:id="@+id/container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<!-- Trying to get the content of the view here -->
</LinearLayout>
<LinearLayout
android:id="@+id/something_else"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
...
<TextView
android:id="@+id/message_sender"
tools:text="Jon Snow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
내가 뭘 하려는지 R.id.container에서 "RowWrapperView"(row_item.xml 중)의 내용을 얻는 것입니다.
내가 누락 된 항목이 있습니까?
사용자 정의보기에서 레이아웃 R.layout.view_row_wrapper를 올바르게 확장합니다. 그러나 R.id.container에서 RowWrapperView 태그 (row_item.xml에 있음)의 내용을 어떻게 얻을 수 있습니까? – Daniel