it seems that similar question about Custom View and button has been
asked at the following thread.
http://groups.google.com/group/android-beginners/browse_thread/thread/d2e84054373d1703/a2bdcf9d824c2cdf?lnk=gst&q=Button+in+Custom+View#a2bdcf9d824c2cdf


I think that I have some workaround to it using XML. It is to call
Custom View in XML with all the required button. First you need to
create your View Constructor with AttributeSet,  declare the XML with
the <merge> tag and call the Custom XML in it with the desire button
layout.
The rest is a business as usual, call setContentView
(R.layout.myCustomlayout); from myActivity in onCreate.


public class myView extends View{
       public myView(Context context,AttributeSet attrs){
               super(context,attrs);

       }
       }
----------------------------
<?xml version="1.0" encoding="utf-8"?>

<merge
       xmlns:android="http://schemas.android.com/apk/res/android";
       xmlns:myView="http://schemas.android.com/apk/res/
com.g1wmhtet.myapp">

       <com.g1wmhtet.myapp.myView
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"

               android:scaleType="center" />

         <LinearLayout
     android:orientation="vertical"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent"
     android:layout_gravity="bottom">
     <TableLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:stretchColumns="*">
        <TableRow>
     <Button
        android:id="@+id/button1"
        android:text="@string/label1" />
     <Button
        android:id="@+id/button2"
        android:text="@string/label2" />
                 </TableRow>
        <TableRow>
     <Button
        android:id="@+id/button3"
        android:text="@string/label3" />
     <Button
        android:id="@+id/button4"
        android:text="@string/label4" />
        </TableRow>
     </TableLayout>
  </LinearLayout>

</merge>

-------------------------------
Here are my references:
http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/
http://groups.google.com/group/android-beginners/browse_thread/thread/1876b8ebc08ae3a7/a747b0a87481bf22?lnk=gst&q=error+inflating+xml+layout+file#a747b0a87481bf22

wmhtet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to