android - Get name of styleable attribute programmatically -


क्या कार्यक्रम को शैलीगत विशेषता का नाम प्राप्त करने का एक तरीका है:

  & lt; declare-styleable name = "TextView" & gt; & Lt; attr name = "DataContext" format = "string" / & gt; & Lt; attr name = "text" format = "string" / & gt; & Lt; / घोषित-Styleable & gt;  

उदाहरण के लिए मुझे "text" से R.styleable.TextView_Text पूर्णांक मान प्राप्त करना चाहते हैं।

आपका स्टाइलिश है:

  & lt; declare-styleable name = "TextView" & gt; & Lt; attr name = "DataContext" format = "string" / & gt; & Lt; attr name = "text" format = "string" / & gt; & Lt; / घोषित-Styleable & gt;  

इसे कॉल करें जहां आप इस के साथ चाहते हैं:

  custom: DataContext = "@ string / xxxx"  

आपके कोड में:

  टाइप किया गयाअरे एक = getContext ()। प्राप्त स्टाइल गुण (attrs, R.styleable.TextView); Int n = a.getIndexCount (); (इंट आई = 0; आई & lt; n; i ++) के लिए {int attr = a.getIndex (i); स्विच (एट्रि) {केस आर। स्टेबल। टेस्ट विव्ही_DataContext: title = a.getString (attr); टूटना; केस R.styleable.TextVie_Text: // आप को तोड़ना चाहते हैं; डिफ़ॉल्ट: लॉग डी। ("टैग", "के लिए अज्ञात विशेषता" + getclass ()। ToString () + ":" + attr); टूटना; }} A.recycle ();  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -