Android custom widget based on existing widgets -


i hope problem understandable because i'm android beginner , english not native.

i create custom widget group couple of textview, progressbar , button. goal able declare custom widget in xml layout file custom attributes define buttons texts, etc ... disposition of inner android widgets same , defined in class.

i have found how declare custom attributes , create custom widget, didn't found documentation nor examples in simple case of placement of existing android widgets. i'am surprising maybe search in wrong direction.

below simple code testing.

custom class :

public class castleviewitem extends view {      private textview item;      public castleviewitem (context c, attributeset attributes) {         super(c, attributes);         item = new textview(c);         typedarray attrs = c.obtainstyledattributes(attributes, r.styleable.castleviewitem);         item.settext(attrs.getstring(r.styleable.castleviewitem_name).tostring());  }     @override     protected void ondraw(canvas canvas) {         super.ondraw(canvas);          // suppose there code add here.     }     @override     protected void onmeasure(int widthmeasurespec, int heightmeasurespec) {         setmeasureddimension(200, 200);         // item.getwidth()/item.getheight() return 0, fixed temporarily value ensure          // widget displayed.     } } 

xml custom attributes declaration :

<resources>     <declare-styleable name="castleviewitem">         <attr name="name" format="string" />     </declare-styleable> </resources> 

xml layout file :

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:ffbdx="http://schemas.android.com/apk/res/bdx.fleurey"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="horizontal" >      <bdx.fleurey.castleviewitem         android:layout_width="wrap_content"         android:layout_height="wrap_content"         ffbdx:name="moat" />  </linearlayout> 

this code display nothing. hope quite clear, in advance answers/advices.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -