2016-10-28 30 views
0

我有一個從EditText擴展的自定義EditText。當用戶將其設置爲自定義EditText時,我想獲取默認的attr android:selectAllOnFocus在自定義視圖中獲取默認的Android attr

我在構造函數中

boolean selecteAllOnFocus = false; 
selectAllOnFocus = attrs.getAttributeBooleanValue("android", "selectAllOnFocus", selectAllOnFocus); 

下面的代碼它是沒有得到的值。有什麼我想念的嗎?

+0

有你完整的URL /路徑命名空間試過嗎?就像這個'http:// schemas.android.com/apk/res/android'。 – Drez

+0

是的,它在xml中有alrady ...'xmlns:android =「http://schemas.android.com/apk/res/android」' – Elye

回答

0

你必須使用完整的命名空間

boolean selecteAllOnFocus = false; 
boolean value = attrs.getAttributeBooleanValue("http://schemas.android.com/apk/res/android", "selectAllOnFocus", selectAllOnFocus) 
相關問題