본문 바로가기

전체 글

안드로이드 - Service 구현 Service는 background에서 처리를 계속할 수 있는 클래스이다. Service는 기본적으로 activity를 가지지 않는다. 서비스를 구현하기 위한 3가지 절차 -- Service 클래스를 확장한 새로운 클래스 정의 -- Manifest file에 Service 선언 추가 -- App에서 Service 실행 1. 서비스를 실행하는 클래스 - 타이머를 이용한 반복 처리. public class MyService extends Service implements Runnable { // 시작 ID private int mStartId; // 서비스에 대한 스레드에 연결된 Handler. 타이머 이용한 반복 처리시 사용. private Handler mHandler; // 서비스 동작여부 flag p.. 더보기
Using WiFi API Android comes with a complete support for the WiFi connectivity. The main component is the system-provided WiFiManager. As usual, we obtain it via getSystemServices() call to the current context. Once we have the WiFiManager, we can ask it for the current WIFi connection in form of WiFiInfo object. We can also ask for all the currently available networks via getConfiguredNetworks(). That gives u.. 더보기
[안드로이드] CheckBox 체크박스 이미지 바꾸기 Button과 거의 흡사하게 만드시면 됩니다. 먼저 이미지에 관련된 파일 하나를 작성합니다. Button을 할때와 마찬가지로 push_checkbox.xml 과 main.xml 두개의 파일에서 작성합니다. 먼저 push_checkbox.xml 파일 내용입니다. 로 작성합니다. button과 다른 점이 있다면 Button은 위의 파일을 Background에다가 작성을 하였다면. CheckBox는 android:button="@drawable/push_checkbox" 를 기입하시면됩니다. 더보기
[안드로이드] 안드로이드 버튼 눌렀을때 이미지 바꾸기 읽기 전에 손가락 한번 꾸~욱 _(__)_ ♥ 감사합니다.^^ ☞ ☜ 안드로이드 버튼 눌렀을때 이미지 바꾸기 버튼 자체 이벤트를 주어서 이미지를 바꾸는 방법도 있지만 여러가지 기능이 들어 가다보면 나름 짜증이나는 일일수 있습니다. 이를 조금 편하게 하기위해 이미지만 바꾸어 주는 파일을 하나 생성하여 구성해주면 참 편리할때가 있습니다. 필요 파일push_button.xml : 바뀔 이미지의 정보 파일 main.xml : 기본 구성 파일 main.xml 은 처름 생성하셨던 그대로 res/layout 폴더에 그대로 갑니다. 그럼 push_button.xml 은 어디로 가느냐. 전 이클립스 헬리오 버전이라 버전마다 폴더 구성은 약간 다를수 있습니다. res/ 폴더 하위에 drawable 라는 폴더를 하나 맹급니.. 더보기
주민번호체크(Java Swing로 구현) import javax.swing.*; import javax.swing.text.*; import java.awt.*; import javax.swing.border.*; import java.awt.event.*; import javax.swing.event.*; public class Jumin extends JPanel implements ActionListener,KeyListener { JPanel top,middle,bottom; JPanel top_top,top_down; JLabel jumin_title,jumin_result_title; JTextField jumin_result; JTextField jumin_left,jumin_right; JButton reset; static in.. 더보기
HorizontalScrollView ScrollBar 위치를 원하는 곳으로 옮기기. 이놈 역시 단순시 scrollTo(int, int)로 쓸것이 아니라 Thread로 조정을 해야 합니다. HorizontalScrollView hsv = (HorizontalScrollView)findViewById(R.id.horizontalView); hsv.post(new Runnable()){ public void run(){ hsv.scrollTo(100, 0); } } 이런 식으로 하시면 됩니다. 더보기
[안드로이드] 다이얼로그 사용법 AlertDialog.Builder alert = new AlertDialog.Builder(this); // 제목, 메시지, icon, 버튼 alert.setTitle(" 알림 "); alert.setMessage(" 무언가를 하고 싶은가요? "); // cancel : false = 단말기 back button으로 취소되지 않음. alert.setCancelable(false); // yes alert.setPositiveButton("Yes", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int id){ //Yes 버튼을 눌렀을때 일어날 일을 서술한다. } }); // no alert.setNeg.. 더보기
[안드로이드] EditText에 이벤트 주기 아무생각없이 EditText에도 습관적으로 setOnClickListener() 로 이벤트를 주곤 했다. 너무나 불편한 현실.... 구글링후 EditText 이벤트는 addTextChangedListener() 를 사용하면 보다 쉽게 다룰수가 있었다. et.addTextChangedListener(new TextWatcher(){ public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void.. 더보기