我想TableLayout
在一个LinearLayout
内扩展一个 XML ScrollView
。
这是我的 main.xml:
<ScrollView..>
<LinearLayout>
<TableLayout>
</TableLayout>
</LinearLayout>
</ScrollView>
这是我用来膨胀 tabletoinflate.xml 的 xml
<TableLayout>
</TableLayout>
tl1 = (TableLayout)getView().findViewById(R.id.tableLayout1); //this exists in the onCreate
//这个方法应该膨胀,但它没有做这项工作
void myMethodToInflate()
{
LayoutInflater inflater =(LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.tabletoinflate, null;
initializeTogglesPost(view);
tl1.removeAllViews();
tl1.addView(view);
}
//这个方法初始化TableLayout里面的24个toggle button来膨胀。
private void initializeTogglesPost(View viewPost)
{
toggleButtonsPost = new ToggleButton[24];
for(int i = 0;i<24;i++)
{
toggleButtonsPost[i] = (ToggleButton)viewPost.findViewWithTag((String) ((i+1) + ""));
toggleButtonsPost[i].setOnClickListener(this);
}
}