[Android] ExpandableLayout: add a setIconAttribute method

Adrien Maglo git at videolan.org
Fri Feb 21 12:00:42 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Feb 21 12:00:28 2014 +0100| [7f7cb25e6f4e8e67c73daa91d2c3e5a548254d2c] | committer: Adrien Maglo

ExpandableLayout: add a setIconAttribute method

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=7f7cb25e6f4e8e67c73daa91d2c3e5a548254d2c
---

 .../src/org/videolan/vlc/widget/ExpandableLayout.java       |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java b/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
index 6da20b8..a7fc338 100644
--- a/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
+++ b/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
@@ -24,6 +24,7 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.interfaces.OnExpandableListener;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -41,10 +42,13 @@ public class ExpandableLayout extends LinearLayout {
     private final LinearLayout mContent;
     private Boolean mExpanded;
     private OnExpandableListener listener = null;
+    private Context mContext;
 
     public ExpandableLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
 
+        mContext = context;
+
         LayoutInflater.from(context).inflate(R.layout.expandable_layout, this, true);
 
         mHeaderLayout = findViewById(R.id.header_layout);
@@ -84,6 +88,13 @@ public class ExpandableLayout extends LinearLayout {
         mIcon.setVisibility(View.VISIBLE);
     }
 
+    public void setIconAttribute(int attrid) {
+        TypedArray a = mContext.getTheme().obtainStyledAttributes(new int[] {attrid});
+        int resId = a.getResourceId(0, 0);
+        a.recycle();
+        setIcon(resId);
+    }
+
     public void setContent(Context context, int resid) {
         View view = LayoutInflater.from(context).inflate(resid, null, true);
         mContent.addView(view);



More information about the Android mailing list