Thursday, 19 January 2012

How to give dynamic values to custom components in android

Hi I have a custom component in my XML and it has static values for textHeader,textValue,textStatsCount,textStatsColor
this is the xml code
<com.my.androproject.customWidget.Textdesigner
   
android:layout_width="122sp"
   
android:layout_height="56sp"
   
android:layout_marginTop="50sp"
   
android:layout_marginLeft="25sp"
   
androproject:textHeader="Operations"
   
androproject:textValue="28"
   
androproject:textStatsCount="+20"
   
androproject:textStatsPercent="+40%"
androproject:textStatsColor="#00FF00" />
In the Textdesigner class
public class Textdesigner extends RelativeLayout {
    // this constructor call will used when instantiating the object manually (not from a layout XML file).
    public Textdesigner (Context context)
    {
        super(context);
        init(context);
    }

    // this from xml layout
    public Textdesigner (Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }
}
  • I want to set the values for textHeader,textValue,textStatsCount,textStatsColor from java code(dynamically). I dont know how to do that??? Please help me..
  • I want to create a new component by using the custom component class Textdesigner ..
can any one help me how to do that in java code... any link or tutorial for learning custom components will be great.. Thanks in advance..
Android, Technology

0 comments:

Post a Comment

´

© 2011 TechDoers - Designed by techDoers