Programming Study
- [java] try catch와 class memory 및 scope 개념 2015.08.10
- [Android] xml에서 question mark(?), 물음표의 의미 2015.08.02
- [Android] xml에서 xmlns:android=“http://schemas.android.com/apk/res/android” 의 의미 2015.08.01
- [Android] xml layout의 tools attribute 2015.08.01
- [C++] iterator 관련 매크로 2015.04.13
- Linux Programing 2014.08.25
[java] try catch와 class memory 및 scope 개념
[Android] xml에서 question mark(?), 물음표의 의미
question mark(?)를 이용하여 xml에서 현재 테마에 맞춰 값을 설정 할 수 있다.
?android:textColorSecondary
?android:attr/textColorSecondary
동일한 의미이며 values/attrs.xml에 설정된 attribute를 이용하는데 이때 해당하는 attribute에 대한 세부 설정은 theme_base.xml에 설정되어있다.
android-support-v7-appcompat
를 예시로 들면
•res/layout/abc_action_bar_home.xml
android:src="?attr/homeAsUpIndicator"
•res/values/attrs.xml
<!-- Specifies a drawable to use for the 'home as up' indicator. -->
<attr name="homeAsUpIndicator" format="reference"/>
•res/values/themes_base.xml
<item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_holo_dark</item>
위와 같은 방식으로 사용하고 있다.
Referencing style attributes
A style attribute resource allows you to reference the value of an attribute in the currently-applied theme. Referencing a style attribute allows you to customize the look of UI elements by styling them to match standard variations supplied by the current theme, instead of supplying a hard-coded value. Referencing a style attribute essentially says, "use the style that is defined by this attribute, in the current theme."
To reference a style attribute, the name syntax is almost identical to the normal resource format, but instead of the at-symbol (@
), use a question-mark (?
), and the resource type portion is optional. For instance:
?[<package_name>:][<resource_type>/]<resource_name>
For example, here's how you can reference an attribute to set the text color to match the "primary" text color of the system theme:
<EditText id="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:text="@string/hello_world" />
Here, the android:textColor
attribute specifies the name of a style attribute in the current theme. Android now uses the value applied to the android:textColorSecondary
style attribute as the value for android:textColor
in this widget. Because the system resource tool knows that an attribute resource is expected in this context, you do not need to explicitly state the type (which would be ?android:attr/textColorSecondary
)—you can exclude the attr
type.
출처: http://developer.android.com/intl/ko/guide/topics/resources/accessing-resources.html
http://stackoverflow.com/a/4771871/5182144
'Programming Study > Android' 카테고리의 다른 글
[Android] xml에서 xmlns:android=“http://schemas.android.com/apk/res/android” 의 의미 (0) | 2015.08.01 |
---|---|
[Android] xml layout의 tools attribute (0) | 2015.08.01 |
uri로 xmlns:android=“http://schemas.android.com/apk/res/android”를 쓰겠다는 의미로 저 uri의 정보를 가져다 쓰겠다는 의미
To understand why xmlns:android=“http://schemas.android.com/apk/res/android”
must be the first in the layout xml file We shall understand the components using an example
Sample
::
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container" >
</FrameLayout>
Uniform Resource Indicator(URI):
- In computing, a uniform resource identifier (URI) is a string of characters used to identify a name of a resource.
- Such identification enables interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols.
Ex:http://schemas.android.com/apk/res/android:id
is the URI here
- XML namespaces are used for providing uniquely named elements and attributes in an XML document.
xmlns:android
describes the android namespace. - Its used like this because this is a design choice by google to handle the errors at compile time.
- Also suppose we write our own
textview
widget with different features compared to androidtextview
, android namespace helps to distinguish between our customtextview
widget and androidtextview
widget
'Programming Study > Android' 카테고리의 다른 글
[Android] xml에서 question mark(?), 물음표의 의미 (0) | 2015.08.02 |
---|---|
[Android] xml layout의 tools attribute (0) | 2015.08.01 |
[Android] xml layout의 tools attribute
xml layout의 tools attribute 는 어떤 activity와 관련되어 있는지 알려준다. Menifest에 테마를 정의하고 있을 시 어떤 테마와 관련이 있는지 editor에게 알려준다. 패키지 이름을 prefix로 가지고 있다. 아래는 참고 자료 원문이다.
tools:context
'Programming Study > Android' 카테고리의 다른 글
[Android] xml에서 question mark(?), 물음표의 의미 (0) | 2015.08.02 |
---|---|
[Android] xml에서 xmlns:android=“http://schemas.android.com/apk/res/android” 의 의미 (0) | 2015.08.01 |
[C++] iterator 관련 매크로
1. all 매크로 관용구
#define all(v) (v).begin(), (v).end()
ex) sort(all(a));
a.erase(unique(all(a)), a.end());
b.insert(b.end(), all(a));
2. FOREACH 매크로
#define FOREACH(it, v) \
for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
ex) FOREACH(it, VectorString)
cout << *it <<endl;
Linux Programing
스마트폰이 느려진 것 같다고 규혁이한데 물어봤더니 프로세스 확인을 해보라고 했는데
나는 바보라 그런거 모른다고 대답하니 돌아오는건 리눅스 공부하란 얘기 ㅠㅠㅠㅠ
그래서 책도 추천을 받아버렸다.
1. 안드로이드 스마트폰에서 리눅스 터미널을 띄우는 방법
1번 방법. 쉘 터미널을 까시오
2번 방법. Abd로 하시오 (둘다 아직 무슨얘긴지 모르니 차차 찾아봐야지)
2. 리눅스 책을 구입하도록 하자
3. 리눅스 기본 사용법
- http://kyuhyuk.kr/310
- http://kyuhyuk.kr/308
- http://kyuhyuk.kr/309
(여기 참고하겠사옵니다 !)