- 안드로이드 애플리케이션 만들기에 접하면서 핵심 파일들과 디렉토리가 너무 많아 찾기 힘들었어요ㅠㅠ
그래서 조사한 주요 파일들과 디렉토리정보 공유해드립니당. 참고하세요><
1. 안드로이드 응용프로그램의 핵심 파일들과 디렉토리
1. AndroidManifest.xml |
AndroidManifest.xml파일은 응용프로그램의 전역 설정을 담는다. 이 파일은 응용프로그램의 능력, 권한, 실행 방식 등 정의 |
2. project.properties |
project.properties 파일은 자동으로 생성되는 프로젝트 파일로, 응용프로그램의 빌드 대상과 기타 적절한 빌드 시스템 옵션들 정의. |
3. src폴더 |
응용프로그램의 모든 소스 코드를 담는 필수 폴더 |
4. bin폴더 |
컴파일된 애플리케이션 코드가 들어감 |
5. gen폴더 |
응용프로그램을 위해 자동으로 생성된 자원(resource)파일들을 담는 필수 폴더. R.java(응용프 로그램 자원 관리자 소스 파일) 자동생성 |
6. res폴더 |
아이콘이나 GUI 레이아웃 등 컴파일된 자바 코드와 함께 애플리케이션 패키지에 포함될 파일 보관 |
7. res/drawable-hdpi/ic_launcher.png |
고해상도 이미지 폴더 |
8. res/drawable-ldpi/ ic_launcher.png |
저해상도 이미지 폴더 |
9. res/drawable-mdpi/ ic_launcher.png |
중해상도 이미지 폴더 |
10.res/layout/main.xml |
단일 화면 레이아웃 파일 |
11.res/values/strings.xml |
응용프로그램 문자열 자원들 |
2. 안드로이드 기본위젯을 사용하여 간단한 계산 어플리케이션 만들기
[Layout .xml]
⦁ 두 정수를 입력한 후에 각 버튼을 누르면 제일 아래에 계산결과가 나오는 간단한 계산기이다.
⦁ 화면 디자인 : EditText2개, Button 4개, TextView 1개
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" //layout 너비 속성
android:layout_height="match_parent"//layout 높이 속성
android:orientation="vertical" > "//부모 뷰. 자식 뷰들을 하나의 행으로 표시할 것인지 하나의 열로 표시할 것인지를 결정한다.
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="수 1" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
========================EditText 1개 중간 생략========================
<Button
android:id="@+id/btnAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="더하기" />
============================버튼 3개 중간 생략==========================
<TextView
android:id="@+id/textResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="계산 결과"
android:textColor="#f0000f" //Text 색상 설정
android:textSize="20dp" /> //Text Size 설정
</LinearLayout>
[결과 레이아웃]
[ Java 코딩 ]
⦁ main.xml의 7개 위젯에 대응할 위젯 변수 7개
⦁ 입력될 2개 문자열을 저장할 문자열 변수 2개
⦁ 계산 결과를 저장할 정수 변수 1개
public class MainActivity extends Activity {
EditText editText1, editText2;
Button btnAdd, btnSub, btnMul, btnDiv;
TextView textResult;
String num1, num2;
Integer result;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("초간단 계산기 만들기_민지");
editText1=(EditText)findViewById(R.id.editText1);
editText2=(EditText)findViewById(R.id.editText2);
btnAdd=(Button)findViewById(R.id.btnAdd);
btnSub=(Button)findViewById(R.id.btnSub);
btnMul=(Button)findViewById(R.id.btnMul);
btnDiv=(Button)findViewById(R.id.btndiv);
textResult=(TextView)findViewById(R.id.textResult);
btnAdd.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
num1=editText1.getText().toString();
num2=editText2.getText().toString();
result=Integer.parseInt(num1)+Integer.parseInt(num2);
textResult.setText("계산 결과 :"+result.toString());
return false;
}
});
'→ 프로그래밍.데이터베이스 > JAVA,JSP,JS' 카테고리의 다른 글
[Android] WebView를 이용하여 안드로이드에서 웹페이지 열어보자. (0) | 2016.10.15 |
---|