मैं एक कस्टम घटक के लिए जिम्मेदार बताते हैं कस्टम पाने के लिए जानने की चाह लोगों के साथ पदों की एक बहुत कुछ देखा है, लेकिन यह मेरे सवाल नहीं है। मैं एक कस्टम घटक बनाया है और मैं विशेषताओं को जोड़ने की कोशिश कर रहा हूँ, लेकिन जब मैं अपने xml फ़ाइल के शीर्ष पर नाम स्थान जोड़ने यह केवल दो यादृच्छिक कस्टम विशेषताओं "paddingEnd" और "paddingStart" पाता है।एंड्रॉयड कस्टम दिखाई नहीं दे विशेषताओं
<resources>
<declare-styleable name="menu_item_attrs">
<attr name="imageId" format="integer" />
<attr name="menuText" format="string" />
</declare-styleable>
</resources>
यह attrs.xml फ़ाइल है।
public MenuListItem(Context context, AttributeSet set) {
super(context, set);
TypedArray a = context.obtainStyledAttributes(set, R.styleable.menu_item_attrs);
if (a == null) {
return;
}
CharSequence s = a.getString(R.styleable.menu_item_attrs_menuText);
if (s != null) {
// do something
}
}
यह मेरी कस्टम कक्षा में निर्माता है।
<LinearLayout
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/expanding_layout"
android:background="#029eed">
<aaron.testappanim.MenuListItem
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
यह मेरा उपयोग करने में घटक है। मैं "imageId" और "menuText" में मान जोड़ना चाहता हूं लेकिन वे उपलब्ध नहीं हैं। दिखाए गए एकमात्र चीजें नीचे दिखाए गए पैडिंग से संबंधित हैं।
कोई भी विचार लोग?
यह मेरे काफी इस सरल समस्या के लिए एक जवाब के लिए इंटरनेट परिशोध के बाद मदद की। धन्यवाद! – chaser