728x90
728x90

1. 안드로이드 CRUD (입력, 수정, 추가, 삭제) 파일구성

 

 

 

2. 코드구성

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:text="새로고침"
        android:id="@+id/btnRefresh"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="추가"
        android:id="@+id/btn_add"/>
    
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="추가"
        android:id="@+id/listView"/>

</LinearLayout>

 

 

MainActivity.java

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:text="새로고침"
        android:id="@+id/btnRefresh"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="추가"
        android:id="@+id/btn_add"/>
    
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="추가"
        android:id="@+id/listView"/>

</LinearLayout>
728x90
728x90
블로그 이미지

coding-restaurant

코딩 맛집에 방문해주셔서 감사합니다.

,

v