안녕하세요

프로그램 과정에서 막혔던 문제들에 대한 해결책 정리


페이지 목록

2011년 2월 25일 금요일

[안드로이드] android.text

본인의 프로그램을 만들 던 중

TextView text; < 이 녀석을 전역으로 설정해 주었다.

그 후 해당 class 내부에서 text.setText("어머나어머나 이러지마세요");

를 만들어 보니,

어머나어머나 이러지마세요 가 뜨지 않는 것이었다.

이게 무슨 귀신 씨나락 까먹고 팥뿌린데 콩나는 시추에이션이란 말인가?

그래서 text1 으로 파일명을 변경해 보았더니, 잘 돌아가더란 말이었던것이었던 말이다.

그래서 text 에 대해 조사해 보니 이와 같은 내용이 나오는 게 아닌가...


package
android.text
Provides classes used to render or track text and text spans on the screen.
You can use these classes to design your own widgets that manage text, to handle arbitrary text spans for changes, or to handle drawing yourself for an existing widget.
The Span… interfaces and classes are used to create or manage spans of text in a View item. You can use these to style the text or background, or to listen for changes. If creating your own widget, extend DynamicLayout, to manages the actual wrapping and drawing of your text.
Interfaces
This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). 
Please implement this interface if your CharSequence has a getChars() method like the one in String that is faster than calling charAt() multiple times. 
Retrieves images for HTML <img> tags. 
Is notified when HTML tags are encountered that the parser does not know how to interpret. 
InputFilters can be attached to Editables to constrain the changes that can be made to them. 
Bit definitions for an integer defining the basic content type of text held in an Editable object. 
This interface should be added to a span object that should not be copied into a new Spenned when performing a slice or copy operation on the original Spanned it was placed in. 
A special kind of Parcelable for objects that will serve as text spans. 
This is the interface for text to which markup objects can be attached and detached. 
This is the interface for text that has markup objects attached to ranges of it. 
When an object of this type is attached to a Spannable, its methods will be called to notify it that other markup objects have been added, changed, or removed. 

An interface for splitting strings according to rules that are opaque to the user of this interface. 
When an object of a type is attached to an Editable, its methods will be called when the text is changed. 
Classes
An AlteredCharSequence is a CharSequence that is largely mirrored from another CharSequence, except that a specified range of characters are mirrored from a different char array instead. 
AndroidCharacter exposes some character properties that are not easily accessed from java.lang.Character. 
Annotations are simple key-value pairs that are preserved across TextView save/restore cycles and can be used to keep application-specific data that needs to be maintained for regions of text. 
This class accesses a dictionary of corrections to frequent misspellings. 
A BoringLayout is a very simple Layout implementation for text that fits on a single line and is all left-to-right characters. 

This class is deprecated. Old text-only interface to the clipboard. See ClipboardManager for the modern API.  
DynamicLayout is a text layout that updates itself as the text is edited. 
Factory used by TextView to create new Editables. 
This class processes HTML strings into displayable styled text. 
This filter will capitalize all the lower case letters that are added through edits. 
This filter will constrain edits not to make the length of the text greater than the specified length. 
A base class that manages text layout in visual elements on the screen. 
Stores information about bidirectional (left-to-right or right-to-left) text within the layout of a line. 
Abstract class for filtering login-related text (user names and passwords)  
This filter is compatible with GMail passwords which restricts characters to the Latin-1 (ISO8859-1) char set. 
This filter rejects characters in the user name that are not compatible with Google login. 
This filter rejects characters in the user name that are not compatible with GMail account creation. 
Convenience equivalent for when you would just want a new Object() for a span but want it to be no-copy. 
Utility class for manipulating cursors and selections in CharSequences. 
Factory used by TextView to create new Spannables. 
This is the class for text whose content is immutable but to which markup objects can be attached and detached. 
This is the class for text whose content and markup can both be changed. 
This is the class for text whose content and markup are immutable. 
StaticLayout is a Layout for text that will not be edited after it is laid out. 
TextPaint is an extension of Paint that leaves room for some extra data used during text measuring and drawing. 

A simple string splitter. 
Enums




이럴 수가....... text 를 instance 명으로 사용하지 않게 조심해야 겠다.

2011년 2월 24일 목요일

[안드로이드] 이클립스 자동완성 없애기

Window - Preferences - Java - Editor - Content Asist 

- (Auto-activation) - Enable (auto-activation)

위와 같이 해주면 된다.

[안드로이드] selector 사용하기

열심히 아무것도 아니더라도 넣어둬야지!!

Layout
만들면서 Selector라는 것을 이용하면 편하다는 것을 배웠다. 줄창 아이폰, WM 6 어플 개발만 하다보니 생소해서 열심히 삽질중이다.

drawable-hdpi
폴더에 모든 리소스 파일을 넣었다. 
(
버튼 , 버튼 다운, 버튼 노말) 요런 것들을 일일히 Touch 이벤트로 받아와서 각각의 이벤트에 맞춰 이미지를 뿌려주었는데 편한 방법이 있었다. 바로 Selector 사용하는 것이었다.

xml
파일의 내용을 살표 보면 다음과 같이 특이할게 없다.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="
http://schemas.android.com/apk/res/android"> 
     <item android:state_pressed="true" android:drawable="@drawable/btn_main_01_on" /> <!-- pressed -->    
 
     <item android:drawable="@drawable/btn_main_01" /> <!-- default -->
 
</selector>

직관적으로 봐도 알겠으니 별도 설명은 생략하고, 이렇게 만든 XML 파일을 적용시키려면 다음과 같이 하면 된다.
<Button
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/creditcard"
     android:background="@drawable/btn_main_01_selector"
     android:layout_marginLeft="66px"
     />

background
속성에 drawble 버튼에 적용될 selector.xml파일을 링크 시켜주면 에뮬레이터 상에서 실행시키면 반응한다. 후다닥 사용해 것을 권장한다.!