How to use viewgroup
I am developing a home activity which countain a video surfaceview and
multiple menu grids and other items on top of first menu,
I wanted to inflate other grid layout on top of this.. second level of
menu considering home.xml as first level of menu and then having multiple
menu on top of second menu.
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.home);
}
home.xml
<FrameLayout
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.example.android.home.CSurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
</com.example.android.home.CSurfaceView>
<LinearLayout
android:id="@+id/wizhome"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_gravity="center">
<GridView android:id="@+id/all_apps"
android:layout_weight="1.0"
android:layout_height="0dip"
android:layout_width="1200dp"
android:persistentDrawingCache="animation|scrolling"
android:alwaysDrawnWithCache="true"
android:scrollbars="none"
android:drawSelectorOnTop="false"
android:listSelector="@drawable/grid_selector"
android:numColumns="4"
android:columnWidth="500dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:stackFromBottom="true"
android:paddingTop="10dp"
android:layout_gravity="center_horizontal"
android:verticalSpacing="15dp"
android:horizontalSpacing="10dp"
android:visibility="visible" / >
</LinearLayout>
</FrameLayout>
second.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayoutsecond"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="214dp"
android:layout_height="wrap_content"
android:gravity="bottom"
android:text="Button Settings"
android:drawableLeft="@drawable/ic_action_add"
/>
<LinearLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="545dp"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.80"
android:gravity="center"
android:orientation="vertical" >
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:columnWidth="90dp"
android:horizontalSpacing="5dp"
android:verticalSpacing="5dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:gravity="center"
>
</GridView>
<Button
android:id="@+id/buttonEmpty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical|center_vertical|center_horizontal"
android:text="Done" />
</LinearLayout>
</LinearLayout>
From first activity, I have to inflate the second.xml or third.xml
depending on the grid item chosen from home.xml..
second.xml and third.xml have their corresponding
public class second_xml extends ViewGroup implements View.OnClickListener
{
@Override
public void onClick(View arg0) {
//do something
}
}
public class third_xml extends ViewGroup implements View.OnClickListener
{
}
What the proper way of inflating this xml view, on the first menu.. And
linking the click and touch events of this layout into second_xml class..
I dont know,how I will transfer all click events of second.xml into
second_xml class Or what is the proper way of inflating this layout and
linking events with their corresponding class
No comments:
Post a Comment