80,348
社区成员
发帖
与我相关
我的任务
分享
<LinearLayout
style="@style/mgs_area1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/mgs_area1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/detail_h2"
android:textSize="18sp" />
<LinearLayout
style="@style/mgs_area2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
//从这个开始每个区域不一样
<TableRow></TableRow>
<xxxxx></xxxxx>
</LinearLayout>
</LinearLayout>
<com.my.hy.pingtan.common.view.ContextArea
android:layout_width="match_parent"
android:layout_height="wrap_content">
//从这个开始每个区域不一样
<TableRow></TableRow>
<xxxxx></xxxxx>
</com.my.hy.pingtan.common.view.ContextArea>
public class ContextArea extends LinearLayout {
private TextView titleText;
private LinearLayout linearLayout;
public ContextArea(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
// 加载布局
View view = LayoutInflater.from(context).inflate(R.layout.comm_context_area, this);
titleText = (TextView) view.findViewById(R.id.context_area_title);
linearLayout = (LinearLayout) view.findViewById(R.id.context_area_linearLayout);
}
//设置标题
public void setTitleText(String title) {
this.titleText.setText(title);
}
public TextView getTitleText() {
return titleText;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (getChildCount()>2){
for (int i=0;i<getChildCount();i++){
Log.d("11111111111111111111111",getChildAt(i).getId()+"");
}
}
}
}
这个是对应的comm_context_area.xml页面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/mgs_area1">
<TextView
android:id="@+id/context_area_title"
style="@style/mgs_area1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/detail_user_h2"
android:textSize="18sp" />
<LinearLayout
android:id="@+id/context_area_linearLayout"
style="@style/mgs_area2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>