System.out.println("Hello, World");

안드로이드 - Button과 EditText


Button

- 사용자가 클릭하여 명령을 내릴수 있는 위젯이며 대부분의 운영체제나 장비에서 아주 흔하게 사용된다. 

  사각형 모양이며 표면에 명령의 의미를 설명하는 문자열이 표시도어 있다. 클래스명이 Button이므로 XML 엘리멘트 이름도 당연히 Button이다. 

  속성은 대부분 View나 TextView로부터 상속받은 것이며 고유의 속성을 따로 가지지 않는다.


EditText

- 문자열을 입력받는 위젯이며 간단히 줄여 에디트라고 부른다. TextView의 서브 클래스이므로 TextView의 모든 속성을 사용할 수 있으며 추가

  문자열 편집과 관련된 메서드가 제공한다.


예제)

<EditText

android:id="@+id/edit"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="여기다 입력"

/>

<Button

android:id="@+id/btn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="입력 완료"

/>


<후보단어 보여주는 이벤트 처리코드>

Button btn = (Button)findViewById(R.id.버튼의 ID);

btn.setOnClickListener(new Button.OnClickListener(){

public void onClick(View v){

//클릭했을때의 동작 처리

EditText edit=(EditText)findViewById(R.id.edit);

String str = edit.getText().toString();

Toast.makeText(C03_ButtonEdit.this, str, Toast.LENGTH_SHORT).show();

}

});

}

}

}

});



Posted by 김마농

안드로이드 -ImageView


○ src

 - 출력한 이미지를 지정하는 가장 중요한 속성. 이 속성에 값을 대입하지 않으면 아무것도 보이지 않으므로 반드시 지정해야 한다.

ex) android:src="@drawble/파일명" 

    android:src="@drawble/pride"


○ maxHeight, maxWidth

 - 이미지가 출력될 최대 크기를 지정한다. 별다른 지정이 없으면 이미지의 원래 크기대로 출력되지만 모바일 장비의 해상도가 충분치 않으므로 적당히                                                              제한할 필요가 있다.

ex) android:maxHeight="크기", android:maxWidth="크기"

android:maxHeight="70px", android:maxWidth="120px"


○ adjustViewBounds

 - 이미지의 종횡비를 맞추기 위해 이미지 뷰의 크기를 적당히 조정할 것인가를 지정한다. true or false 둘중 하나의 값만 지정가능하므로 하나만 사용해야 한다.

ex) android:adjustViewBounds="true", android:adjustViewBounds="false"


○ cropToPadding

 - true일 경우 위젯의 주어진 여백에 맞추기 위해 이미지의 일부를 잘라낸다. 이 속성을 사용하면 여백을 강제로 유지하므로 이미지 전체가 다 보이지 않을 수도 있다.


○ tint

 - 이미지에 색조를 입힌다. 색상이 이미지 위에 살짝 덮혀 출력된다. 통상 반투명한 색상을 지정하여 이미지 위에 옅은 색상을 뿌리는 효과를 낸다.

ex) android:tint="#80ff000"


○ scaleType

 - 이미지의 원래 크기와 다르게 출력 할 때 적용할 확대, 축소 방식을 지정한다. matrix, fitXY, center, centerCrop, centerInside 등의 여러 가지 방법 중 하나를 지정한다.


예제)

<ImageView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:src="@drawable/pride"

/>


<ImageView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:src="@drawable/pride"

android:maxHeight="70px"

android:maxWidth="120px"

android:adjustViewBounds="true"

/>


<ImageVIew

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:src="@drawable/dog"

android:tint="#80ff0000"

/>


Posted by 김마농

JSTL(JSP Standard Tag Library)

-custom tag library로 JSP 스펙에는 포함되지 않았지만 자바 진영에서 진행하는 태그 라이브러리

-커스텀 태그 : JSP에서 스크립트릿으로 작성해야할 동적 로직을 태그로 처리

-jstl.java.net에서 api를 다운로드 후 web application의 lib 폴더에 넣어 사용한다.

-JSP에서 커스텀 태그를 사용하기 위해서는 taglib 지시자 태그 설정 필요

 <%@ taglib prefix="접두어" uri="태그 라이브러리 구분자"%>


○ JSTL 종류

-core : Program의 기본적인 내용들을 지원. 변수, 제어문, 출력 등

     uri : http://java.sun.com/jsp/jstl/core


-xml : XML 관련 처리

     uri : http://java.sun.com/jsp/jstl/xml


-국제화 : ResourceBundle을 이용한 국제화 처리

uri : http://java.sun.com/jsp/jstl/fmt


-데이터베이스 : JSP에서 DB 접근하기 위한 로직 지원

uri : http://java.sun.com/jsp/jstl/sql



○ 주요 코어 라이브러리

-변수지원

-set : JSP에서 Attribute로 binding된 객체 처리

-set 태그

1. 4개 속성영역에 값(Attribute)를 binding

                 - 속성

var : binding할 객체 이름

scope : binding할 속성영역. 값 : page, request, session, application

value : binding할 속성 객체

ex)<c:set var="name" scope="request" value="홍길동"/>

<c:set var="errorMessage" scope="request" value="치명적인 오류"/> 

이것을 get할때는 똑같이 ${requestScope.errorMessage}하면 된다.


2. binding된 Attribute의 property에 값을 설정

- 속성

target : property를 설정한 attribute

value : property에 설정할 값

property : 값을 설정할 property

ex) <c:set target="${requestScope.cto}" property="id" value="aaa"/>


-remove 태그

-remove : binding된 attribute 제거

-4개 속성영역에 binding된 attribute 객체를 제거하는 태그

-속성

var : 제거할 속성의 이름

scope : 제거할 속성이 binding된 영역(page, request, session, application)

ex) <c:remove scope="request" var="cto"/>


-제어문 지원

-if : if문

-if 태그

-단일 조건 조건문 처리 -if문과 동일

-다중 조건 처리에는 사용할 수 없다.(if-else)

-속성

-test : 조건 설정 true/false

-구문

<c:if test="조건">조건 만족시 실행할 내용</c:if>

<c:if test="<%=x<10">조건 만족시 실행할 내용</c:if>


-choose : 다중 조건 처리

- 다중 조건을 처리하는 태그 - if else, switch case

- choose 태그는 조건들을 묶어주는 역할

- 하위 태그

when 태그

-선택할 조건을 표기하기 위한 태그

-속성 : test - 조건 설정

-otherwise 

-else의 역할(switch case의 default)의 역할

구문

<c:choose>

<c:when test="조건1">

조건1이 true일 경우 실행할 내용

  </c:when>

<c:otherwise>

when의 모든 조건이 만족하지 않을 경우 실행할 내용

</c:otherwise>

</c:choose>


-forEach : 반복문 처리

> 컬렉션이나 배열을 반복해서 element들을 조회

> 속성

-items : 반복할 컬렉션이나 배열 설정

-var : 반복시 조회할 element를 참조할 변수 선언

ex)<c:forEach var="var" items="배열">

${var.id}

    </c:forEach>


> 특정 횟수만큼 반복을 처리

-begin : 시작 값

-end : 종료 값

-step : 증감 값

-var : 변화되는 값을 저장할 변수 선언

ex)<c:forEach begin="1" end="10" step="1" var="i">

${ i } - 안녕

</c:forEach>



ex) if문 적용하기


-출력지원

-out 태그

-태그형태의 문자열을 그대로 출력되도록 처리할 수 있다.

-속성

-value : 출력할 내용

-escapeXml : 태그 출력 여부 처리

-true : 태그를 해석하지 않고 그대로 출력

-false : 태그를 해석해서 출력

-default : value의 값이 null일 경우 출력할 기본 값

ex) 그냥 출력하기


ex) EL과 연동


ex) 출력할때 태그 연동하기


ex) null값 출력 및 기본 값 


위 그림처럼 requestScope에 아무것도 없으면 null값이 출력된다. 또한 default="값"에다가 값을 넣으면 기본값이 출력된다.



또한 default에 안넣는다고 해도 <c:out> 값 </c:out>에 값을 넣어도 기본값으로 나온다.


Posted by 김마농

1. http://jstl.java.net/로 들어가서 다운로드를 클릭한다.



2. JSTL API를 클릭한다.


3. javax.servlet.jsp.jstl-api-1.2.1.jar을 다운 받는다.


4. 다시 뒤로 돌아와서 JSTL Implementation을 선택한다.


5. javax.servlet.jsp.jstl-1.2.1.jar을 다운받는다.


6. 다운받은 2파일을 lib 폴더에 넣으면 자동으로 적용된다.



Posted by 김마농