Why I can't get values fromdeclare styleable TypedArray via obtainStyledAttributes?
<p>I created a custom control, and define some attributes in attri.xml, but I can't get values fromdeclare styleable TypedArray via obtainStyledAttributes, could you help me check what's wrong about my codes?</p>

<p>/res/values/attrs.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
    &lt;declare-styleable name="TopBar"&gt;
        &lt;attr name="title2" format="string" /&gt;
        &lt;attr name="titleTextSize2" format="dimension" /&gt;
        &lt;attr name="titleTextColor2" format="color" /&gt;
        &lt;attr name="leftTextColor" format="color" /&gt;
        &lt;attr name="leftBackground" format="color|reference" /&gt;
        &lt;attr name="leftText" format="string" /&gt;
        &lt;attr name="rightTextColor" format="color" /&gt;
        &lt;attr name="rightBackground" format="color|reference" /&gt;
        &lt;attr name="rightText" format="string" /&gt;
    &lt;/declare-styleable&gt;
&lt;/resources&gt;
</code></pre>

<p>/res/layout/activity_main.xml</p>



<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"&gt;

    &lt;com.qihoo.foo.TopBar
        android:id="@+id/topbar"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        myapp:leftBackground="@drawable/left"
        myapp:leftText="Back"
        myapp:leftTextColor="#ffffff"

        myapp:rightBackground="@drawable/right"
        myapp:rightText="Move"
        myapp:rightTextColor="#ffffff"

        myapp:title2="title"
        myapp:titleTextColor2="#123412"
        myapp:titleTextSize2="18sp"
        &gt;

    &lt;/com.qihoo.foo.TopBar&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>/com.foo.samples/TopBar.java</p>

<pre><code>private void init(Context context, AttributeSet attrs, int defStyle) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Toolbar);

        // I can't get any value from below codes
        mLeftTextColor = ta.getColor(R.styleable.TopBar_leftTextColor, 0);
        mLeftBackground = ta.getDrawable(R.styleable.TopBar_leftBackground);
        mLeftText = ta.getString(R.styleable.TopBar_leftText);

        mRightTextColor = ta.getColor(R.styleable.TopBar_rightTextColor, 0);
        mRightBackground = ta.getDrawable(R.styleable.TopBar_rightBackground);
        mRightText = ta.getString(R.styleable.TopBar_rightText);

        mTitleTextSize = ta.getDimension(R.styleable.TopBar_titleTextSize2, 10);
        mTitleTextColor = ta.getColor(R.styleable.TopBar_titleTextColor2, 0);
        mTitle = ta.getString(R.styleable.TopBar_title2);

        ta.recycle();
    }
</code></pre>