dear all,

I try to implement a custom button(OnPressButton), and the code is in
below.
In LogCat, I can see the two parameters (btn_up/btn_down) value are
below:

btn_...@drawable/btn_up
btn_do...@drawable/btn_up

But how can I convert this to point to R.drowable.btn_up and
R.drowable.btn_down ?

Thank you.

Ryan

#############################################################
In res/layout/main.xml
#############################################################
    <studio.hansung.mobile.tools.ui.OnPressButton
        xmlns:android="http://schemas.android.com/apk/res/android";
        xmlns:app="http://www.mydomain.test/apk/res/mydomain..tools.ui";
        android:id="@+id/btn_opb"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
                app:btn_up="@drawable/btn_up"
                app:btn_down="@drawable/btn_up"
                />

#############################################################
In my Activity class
#############################################################
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        OnPressButton opb = (OnPressButton) findViewById
(R.id.btn_opb);
    }
#############################################################
In my custom button class: OnPressButton.java
#############################################################
        Properties params = null;

        public OnPressButton(Context context, AttributeSet attrs) {
                super(context, attrs);

                // get all params in layout xml
                params =  new Properties();

                for(int i=0; i<attrs.getAttributeCount();i++) {
                        Log.d(tag, "attrs value=" + attrs.getAttributeValue(i));
                        Log.d(tag, "attrs name=" + attrs.getAttributeName(i));
                        
params.put(attrs.getAttributeName(i),attrs.getAttributeValue(i));
                }

                if(params.containsKey("btn_up")) {
                        btn_up = (String)params.get("btn_up");
                        Log.d(tag, "btn_up=" + btn_up);
                }

                if(params.containsKey("btn_down")) {
                        btn_down = (String) params.get("btn_down");
                        Log.d(tag, "btn_down=" + btn_down);
                }
}








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

Reply via email to