수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

안드로이드 초보입니다. 제발 알려주세요

늘봄

2023.04.01

안드로이드 완전 초보입니다. 하나라도 아시는 분은 부탁드려요! 제발!!

1. 소스 분석 좀 부탁드려요.
package corea.com.preference1;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.EditText;
public class Preference1Activity extends Activity {

EditText edit;
CheckBox check1, check2;
SharedPreferences pref;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

pref = getSharedPreferences(pref, Activity.MODE_PRIVATE);
edit = (EditText)findViewById(R.id.edit);
check1 = (CheckBox)findViewById(R.id.check1);
check2 = (CheckBox)findViewById(R.id.check2);

String text = pref.getString(editText,);
Boolean chk1 = pref.getBoolean(check1, false);
Boolean chk2 = pref.getBoolean(check2, false);

edit.setText(text);
check1.setChecked(chk1);
check2.setChecked(chk2);}

public void onPause(){
super.onPause();

pref = getSharedPreferences(pref, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();

edit = (EditText)findViewById(R.id.edit);
check1 = (CheckBox)findViewById(R.id.check1);
check2 = (CheckBox)findViewById(R.id.check2);

editor.putString(editText, edit.getText().toString());
editor.putBoolean(check1, check1.isChecked());
editor.putBoolean(check2, check2.isChecked());
editor.commit();
}}

2. getItem(), getItemId()함수를 제거하면 어떤 현상이 발생하는것과 이유.
package corea.com.sss;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
public class SssActivity extends Activity {
/** Called when the activity is first created. */
Integer[] images = {
R.drawable.icon1, R.drawable.icon2, R.drawable.icon3, R.drawable.icon4,
R.drawable.icon5, R.drawable.icon6, R.drawable.icon7
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Gallery gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView? parent,
View v, int position, long id){
ImageView imageView = (ImageView) findViewById(R.id.image1);
imageView.setImageResource(images[position]);
}
});
}
public class ImageAdapter extends BaseAdapter{
private Context context;

public ImageAdapter(Context c)
{
context = c;
}
public int getCount(){
return images.length;
}
public Object getItem(int position){
return position;
}
public long getItemId(int position){
return position;
}
public View getView(int pos, View convertView, ViewGroup parent){
ImageView imageView;

if(convertView == null){
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new
Gallery.LayoutParams(150, 120));
}else
imageView = (ImageView)convertView;
imageView.setImageResource(images[pos]);
return imageView;
}}}

3. 버튼과 에디트 텍스트의 순서를 변경하면 결과는?
FrameLayout xmlns:android=http://schemas.android.com/apk/res/android
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=fill_parent
TextView
android:layout_width=fill_parent
android:layout_height=wrap_content
android:text=@string/hello/
EditText
android:text=EditText
android:id=@+id/EditText01
android:layout=width=wrap_content
android:layout=height=wrap-content/
Button
android:text=Button
android:id=@+id/Button01
android:layout_height=wrap_content
android:layout_width=fill_parent/
/FrameLayout

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2699547 [급]레이어보다 object태그가 우선순위가 되는 문제 (5) DevilsTears 2025-06-27
2699518 javaScript중복체크 하는법좀.. 알려주세요 (3) 비 2025-06-26
2699495 이런 탭메뉴를 뭐라고 해야 하는지 모르겠네요 (1) 들빛 2025-06-26
2699380 메뉴가 계단식으로 나타나요.. ㅠ.ㅠ (5) 스릉흔다 2025-06-25
2699354 영문 웹폰트 관련 질문입니다!!! (1) 치킨마루 2025-06-25
2699329 윈도우 미디어 플레이어 URL 질문!!! (1) 제철 2025-06-25
2699296 동영상 배경 질문드려요!!!!!!!!!!!!!! 핫파랑 2025-06-24
2699214 position:fixed 에 대한 질문입니다.. (7) 사이 2025-06-24
2699183 제이쿼리 이미지 슬라이드 위치값 수정 초엘 2025-06-23
2699153 테마[ADORABLE]에서 페이지생성시 하위페이지는 2개밖에 안되나요? 흰여울 2025-06-23
2699129 네이버 블로그 또는 사이트의 글을 불러오기 갤원 2025-06-23
2699070 탭메뉴처럼 셀렉트 박스를 이용해서 내용을 출력할 수 있는 방법이 있을까요. (3) 큰꽃늘 2025-06-22
2699016 인터넷이 안되는 환경에서 validator설치방법 (3) 은송이 2025-06-22
2698988 대체 C++ 6.0 exe 아이콘은 어떻게 넣는건가요? 외국녀 2025-06-22
2698960 음성파일을 embed로 작업했는데..웹 표준코딩으로 변경하려면 어떻게 해야하나요? (1) 잎새 2025-06-21
2698932 메뉴목록 풍선창 만들기 html (2) 하늘이 2025-06-21
2698901 http://www.zeitgeistbot.com/ 이 사이트처럼 움직이는 효과를 무엇이라고 하나요? 누림 2025-06-21
2698876 table width값 크로스브라우징에 대한 문의 (2) 볼수록매력 2025-06-21
2698849 c언어 질문. (3) 아름나 2025-06-20
2698823 setInterval 이벤트 제거 하려면... 가온길 2025-06-20
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com