1. 데이터 베이스의 shop table row를 모두 불러와 리스트 뷰로 옮기기

2. 커스텀 리스트 뷰를 만들어 실제 사용 가능한 UI/UX 구현을 진행 예정

3. 데이터베이스를 불러 오는 과정에서 PHP -> JSON변환이 OBJECT, ARRAY 방식의 차이로 인해 계속 오류가 발생하여 6시간을 잡아먹었음.. JSON에 대해서 조금 더 공부해봐야할듯.

 

JSONObject jsonObject = new JSONObject(jsonString);
JSONArray jsonArray = jsonObject.getJSONArray("webnautes");
jsonString = fromdoInBackgroundString;
shopArrayList = doParse();
Log.d(TAG, shopArrayList.get(0).getName());
textView.setText(shopArrayList.get(0).getName());
textView2.setText(shopArrayList.get(0).getDescription());
textView3.setText(shopArrayList.get(0).getField());

 

E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]

 

 

https://github.com/Damnun/Android_SoonBapSang

 

GitHub - Damnun/Android_SoonBapSang: 안드로이드 프로그래밍, JAVA를 이용해 순밥상 어플을 제작

안드로이드 프로그래밍, JAVA를 이용해 순밥상 어플을 제작. Contribute to Damnun/Android_SoonBapSang development by creating an account on GitHub.

github.com

 

<?php 
    error_reporting(E_ALL); 
    ini_set('display_errors',1); 

    include('connect.php');
        
    $stmt = $con->prepare('select * from shop');
    $stmt->execute();

    if ($stmt->rowCount() > 0)
    {
        $data = array(); 

        while($row=$stmt->fetch(PDO::FETCH_ASSOC))
        {
            extract($row);
    
            array_push($data, 
                array('shop_No'=>$shop_No,
                'shop_name'=>$shop_name,
                'shop_description'=>$shop_description,
                'shop_likes'=>$shop_likes,
                'shop_image'=>$shop_image,
                'shop_location_latitude'=>$shop_location_latitude,
                'shop_location_longitude'=>$shop_location_longitude,
                'shop_field'=>$shop_field
            ));
        }

        header('Content-Type: application/json; charset=utf8');
        $json = json_encode(array("webnautes"=>$data), JSON_PRETTY_PRINT+JSON_UNESCAPED_UNICODE);
        echo $json;
    }

?>

 

1. 데이터베이스의 내용을 PHP JSON 형식으로 받아오는 코드를 작성

- 초반에는

<?php 
    $con = mysqli_connect();
    mysqli_query($con, 'SET NAMES utf8');

    $statement = mysqli_prepare($con, "SELECT * FROM shop");

    mysqli_stmt_execute($statement);
    mysqli_stmt_store_result($statement);

    $response = array();
    $response["success"] = false;

    while(mysqli_stmt_fecth($statement)) {
        $response["shop_No"] = $shop_No;
        $response["shop_name"] = $shop_name;
        $response["shop_description"] = $shop_dsecription;
        $response["shop_likes"] = $shop_likes;
        $response["shop_image"] = $shop_image;
        $response["shop_location_latitude"] = $shop_location_latitude;
        $response["shop_location_longitude"] = $shop_location_longitude;
        $response["shop_field"] = $shop_field;
    }

        echo json_encode($response);
?>

형식으로 받으려고 했으나 mysqli가 계속해서 오류가 발생하여 위의 방식으로 수정하였음.

 

 

2. Android Vritual Device가 계속 오류가 나고(삭제했던 기기가 계속 있다고 나옴) IDE 상에서 오류가 너무 많은 것 같아 physical device를 설치하여 관리하기로 하였음.

 

3. 불필요한(사용하지 않는) php파일을 정리하고, 기존 php파일의 code structure를 개선하였음

 

 

 

내일은 받아온 json 데이터를 가공하여 custom list view를 만들어 앱 화면에 띄우는 기능을 추가하려 한다.

 

+ Recent posts