tags:

views:

15

answers:

1

                                                                        <LinearLayout
                                                                                        xmlns:android="http://schemas.android.com/apk/res/android"
                                                                                        android:orientation="vertical"
                                                                                        android:id="@+id/llAddNote"
                                                                                        android:layout_width="fill_parent"
                                                                                        android:layout_height="wrap_content"
                                                                                        android:layout_marginRight="8dip"
                                                                                        android:background="#CCFFCC">

                                                                                        <TextView
                                                                                                    android:layout_width="wrap_content"
                                                                                                    android:layout_height="wrap_content"
                                                                                                    android:layout_margin="24dip"
                                                                                                    android:text="Add Notes"/>
                                                                                        <TableLayout
                                                                                                            android:layout_width="fill_parent"
                                                                                                            android:layout_height="wrap_content"
                                                                                                            android:layout_marginLeft="24dip"
                                                                                                            android:layout_marginRight="24dip"
                                                                                                            android:id="@+id/tlNotes"
                                                                                                            android:stretchColumns="0">
                                                                                        </TableLayout>

                                                                                        <Button
                                                                                                            android:id="@+id/bAddNoteLine"
                                                                                                            android:layout_marginLeft="24dip"
                                                                                                            android:layout_width="wrap_content"
                                                                                                            android:layout_height="wrap_content"

                                                                                                            android:text="ADD">
                                                                                        </Button>

                                                                                        <LinearLayout
                                                                                                            android:id="@+id/llIndex"
                                                                                                            android:orientation="horizontal"
                                                                                                            android:layout_width="fill_parent"
                                                                                                            android:layout_height="wrap_content"
                                                                                                            android:layout_margin="21dip"
                                                                                                            android:gravity="center">
                                                                                                            <Button
                                                                                                                    android:id="@+id/bSaveSubjectiveNote"
                                                                                                                    android:layout_width="192dip"
                                                                                                                    android:layout_height="wrap_content"
                                                                                                                    android:text="Save"/>
                                                                                                            <Button 
                                                                                                                    android:id="@+id/bDiscardSubjectiveNote"
                                                                                                                    android:layout_width="192dip"
                                                                                                                    android:layout_height="wrap_content"
                                                                                                                    android:layout_marginLeft="48dip"
                                                                                                                    android:background="@drawable/button"
                                                                                                                    android:text="Discard"/>
                                                                                        </LinearLayout>                                                                                                                 

                                                                        </LinearLayout>

how to retrieve the index of linearLayout which has "llIndex" as id. Thanks

A: 

When you create the XML, there is a file yourpackage.generated.R.java that is created with all the ids/drawables/etc in it. So to reference it, import the generated R.java into your class, then do this (assuming you're in an Activity):

setContentView(R.layout.my_content);
LinearLayout addNoteLayout = (LinearLayout) findViewById(R.id.llAddNote);
Daniel Lew
Thanks for your response...But actually i want index, Now in this example the index of linearLayout which has "llIndex" as id is 3 .I want to read it through api.
Well I guess I am confused because what exactly do you want the index of? Is llAddNote contained within another view, and you need to know which child # it is?
Daniel Lew