Code example for TypedArray

Methods: getColor

0
        int[] attrs = new int[]{attr};
        Context context = GlobalContext.getInstance().getActivity();
//        if (context == null) 
//            context = GlobalContext.getInstance(); 
        TypedArray ta = context.obtainStyledAttributes(attrs);
        return ta.getColor(0, 430);
 
    } 
 
    //can't find a public theme attr to modify actionbar searchview text color 
    public static void customActionBarSearchViewTextColor(SearchView searchView) {
        int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
        TextView textView = (TextView) searchView.findViewById(id);
        textView.setTextColor(Color.WHITE);
 
    } 
 
}