songining
[์•ˆ๋“œ๋กœ์ด๋“œ] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๋™ (sqlite)
ANDROID 2020. 8. 6. 02:09

๋ชจ๋‹์ฝ”๋”ฉ์•ฑ์„ ๋งŒ๋“ค๋ฉด์„œ ์‚ฌ์šฉ์ž์˜ ๋‹‰๋„ค์ž„, ์ด๋ฉ”์ผ, ์„ ํƒํ•œ ์–ธ์–ด, ์ฆ๊ฒจ์ฐพ๋Š” ๋ฌธ์ œ๋ฅผ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ €์žฅํ•ด์•ผ ํ•  ์ผ์ด ์ƒ๊ฒผ๋‹ค. ๊ฐ๊ฐ์˜ ์‚ฌ์šฉ์ž๋งˆ๋‹ค ์„ ํƒํ•œ ์–ธ์–ด์™€ ๋ฌธ์ œ๋“ค์ด ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ฒ˜์Œ์—๋Š” php๋ฅผ ์ค‘๊ฐ„์— ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋‚˜ ์ƒ๊ฐํ•ด์„œ XAMPP๋ฅผ ๊น”๊ณ  ๋‚œ๋ฆฌ๋ฅผ ํ”ผ์› ๋Š”๋ฐ ๊ฒฐ๊ตญ sqlite API๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ข‹์€ ์„ ํƒ์ด์—ˆ๋‹ค. SQLiteOpenHelper๋ฅผ ์ƒ์†๋ฐ›๋Š” DBHelper๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์•ˆ๋“œ๋กœ์ด๋“œ developer๊ฐ€์ด๋“œ์— ๋”ฐ๋ผ ๋ฉ”์†Œ๋“œ๋“ค์„ ๊ฐ๊ฐ ๊ตฌํ˜„ํ•˜์˜€๋‹ค. ์œ„์˜ ๋ฉ”์†Œ๋“œ๋“ค์€ ์›ํ•˜๋Š” ์‹คํ–‰๋ถ€๋ถ„์—์„œ ๊ฐ๊ฐ ํ˜ธ์ถœํ•˜์—ฌ ์‚ฌ์šฉํ•ด์ฃผ๋ฉด ๋œ๋‹ค. import android.content.ContentValues; import android.content.Context; import android.database.Cu..

article thumbnail
[์•ˆ๋“œ๋กœ์ด๋“œ] ์นด์นด์˜ค ๋กœ๊ทธ์ธ ์—ฐ๋™
ANDROID 2020. 8. 3. 00:37

์šฐ์„  Kakao Developer์—์„œ ์•ฑ์„ ๋งŒ๋“ค๊ณ  ํ™œ์„ฑํ™”์„ค์ •, ํ•ด์‹œํ‚ค์ž…๋ ฅ ๋“ฑ ๋ชจ๋“  ์ค€๋น„๋ฅผ ๋๋ƒˆ๋‹ค๊ณ  ์น˜์ž. (์นด์นด์˜ค ์‚ฌ์šฉ์ž ์ •๋ณด ๋™์˜๋ฅผ ํ•„์ˆ˜ ๋˜๋Š” ์„ ํƒ์œผ๋กœ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์€ ์ •๋ง ์ค‘์š”ํ•˜๋‹ค. ์ด๊ฑธ ํ™•์ธ ์•ˆํ•˜๊ณ  ์ฝ”๋“œ๋งŒ ๊ณ„์† ๊ณ ์น˜๋‹ค๊ฐ€ ๊ฑฐ์˜ ์ผ์ฃผ์ผ์„ ๊ณ ์ƒํ–ˆ๋‹ค. ์‚ฌ์šฉ์ž์ •๋ณด ๋™์˜ ์„ค์ •๊ณผ ๋กœ๊ทธ์ธ ํ™œ์„ฑํ™”๋Š” ์ •๋ง ํ•„์ˆ˜๋‹ค.) ์ด์ œ ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์— ์ž…๋ ฅํ•  ์ฝ”๋“œ๋“ค์ด๋‹ค. //application ๋ฐ–์— //์ธํ„ฐ๋„ท ์‚ฌ์šฉ๊ถŒํ•œ ์„ค์ • //application ์•ˆ์— dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.const..

[์•ˆ๋“œ๋กœ์ด๋“œ] intent ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๊ฐ’ ๋„˜๊ธฐ๋Š” ๋ฐฉ๋ฒ•
ANDROID 2020. 8. 3. 00:10

BottomUp ํ”„๋กœ์ ํŠธ๋ฅผ ํ•˜๋ฉด์„œ ๋งŒ๋“  ์•ฑ์—์„œ ์นด์นด์˜ค๋กœ๊ทธ์ธ์—ฐ๋™ํ•˜์—ฌ ๋ฐ›์•„์˜จ ๊ฐ’์„ ๋‹ค์Œํ™”๋ฉด์œผ๋กœ ๋„˜๊ฒจ์ฃผ๊ณ  ์‹ถ์—ˆ๋‹ค. ๋‹‰๋„ค์ž„๊ณผ ์ด๋ฉ”์ผ๊ฐ’ ๋‘๊ฐ€์ง€๋ฅผ ์ „๋‹ฌํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์–ด๋–ป๊ฒŒ ํ•  ์ง€ ๊ณ ๋ฏผํ•˜๋‹ค๊ฐ€ ArrayList๋ฅผ ์‚ฌ์šฉํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. ArrayList ๊ฐ์ฒด profile์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ  profile์— ๋ฐ›์•„์˜จ nickname๊ณผ email์„ ๋„ฃ์–ด์ฃผ์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  putExtra์— profile์„ ๋„˜๊ฒจ์ฃผ์—ˆ๋‹ค. ArrayList profile=new ArrayList(); profile.add(nickname); profile.add(email); Intent intent = new Intent(this, HomeActivity.class); intent.putExtra("profile",profile); startAct..

[์•ˆ๋“œ๋กœ์ด๋“œ] SharedPreference ์‚ฌ์šฉ๋ฒ• (ํ˜„์žฌ ๋ฐ์ดํ„ฐ ์ €์žฅ/์•ฑ ์„ค์ • ๋งŒ๋“ค ๋•Œ ์œ ์šฉ)
ANDROID 2020. 8. 2. 16:55

์ €์žฅํ•˜๊ณ  ์‹ถ์€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌธ์ž์—ด์ผ ๊ฒฝ์šฐ //ํ•„๋“œ String shared = "file"; //oncreate() SharedPreferences sharedPreferences = getSharedPreferences(shared,0); String value=sharedPreferences.getString("song",""); //์ €์žฅ๋œ ๊ฒƒ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ/์ €์žฅ๋œ ๊ฒƒ์„ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๊ฒƒ์ด๋ฏ€๋กœ ์˜ค๋ฅธ์ชฝ์—๋Š” ์•„๋ฌด๊ฒƒ๋„ ์ ์œผ๋ฉด x et_save.setText(value); //ondestroy() //์ข…๋ฃŒ์ง์ „์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ SharedPreferences sharedPreferences=getSharedPreferences(shared,0); SharedPreferences.Editor editor = sharedPre..

article thumbnail
[์•ˆ๋“œ๋กœ์ด๋“œ] ListView ์‚ฌ์šฉ๋ฒ•
ANDROID 2020. 8. 2. 16:54

ํ•ด๋‹น xml์„ ์ด์šฉํ•˜์—ฌ list = findViewById(R.id.list); ๋ฅผ ์ด์šฉํ•ด java์— list ๊ฐ์ฒด๋ฅผ ๋งŒ๋“  ํ›„ ArrayList์™€ ์—ฐ๊ฒฐ์‹œ์ผœ์•ผ ํ•œ๋‹ค. List data=new ArrayList(); ์œ„์˜ ์ฝ”๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ ArrayList ๊ฐ์ฒด์ธ ๋ฌธ์ž์—ด ํƒ€์ž…์˜ data ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค. ์ด์ œ ArrayList์™€ ListView๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. ArrayAdapter๊ฐ€ ์—ฌ๊ธฐ์„œ ์ค‘๊ฐ„๋‹ค๋ฆฌ ์—ญํ• ์„ ํ•˜๊ฒŒ ๋œ๋‹ค. ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,data); //this? ํ˜„์žฌ Activity์— ํ•ด๋‹น๋œ๋‹ค list.setAdapter(adapter);โ€‹ ์œ„์˜ ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ArrayAdapt..

[์•ˆ๋“œ๋กœ์ด๋“œ] ๋กœ๊ทธ์ธ ์—ฐ๋™ HashKey ์–ป๋Š” ๋ฐฉ๋ฒ•
ANDROID 2020. 8. 2. 16:52

์•ˆ๋“œ๋กœ์ด๋“œ ์•ฑ์— ์นด์นด์˜ค ๋กœ๊ทธ์ธ ์—ฐ๋™์„ ํ•˜๊ธฐ์œ„ํ•ด ํ•ด์‹œํ‚ค ๊ตฌํ•˜๋Š” ๋ฒ•์„ ์•Œ์•„๋ณด์•˜๋‹ค. private void getHashKey(){ PackageInfo packageInfo=null; try{ packageInfo= getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e){ e.printStackTrace(); } if(packageInfo==null){ Log.e("HashKey","HashKey:null"); } for(Signature signature:packageInfo.signatures){ try{ MessageDi..

[์•ˆ๋“œ๋กœ์ด๋“œ] ํ™”๋ฉด ์ „ํ™˜ ๋ฐฉ๋ฒ•
ANDROID 2020. 8. 2. 16:51

btn_move=findViewById(R.id.btn_move); btn_move ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ ํ™”๋ฉด์ด ์ „ํ™˜๋˜๋„๋ก ํ•˜๋ ค๋ฉด? //move๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰๋˜๋Š” ๋ฉ”์†Œ๋“œ btn_move.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { str=et_move.getText().toString(); //๊ฐ์ฒด ์ƒ์„ฑ Intent intent=new Intent(MainActivity.this,SubActivity.class); intent.putExtra("str",str);//๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด๋Š”๋‹ค. startActivity(intent); //์•กํ‹ฐ๋น„ํ‹ฐ ์ด๋ฆ„ } }); Intent ๊ฐ์ฒด์ธ intent๋ฅผ ๋งŒ๋“ ๋‹ค. (..

[์•ˆ๋“œ๋กœ์ด๋“œ] ์•ฑ์— ๋™์  ๋ณ€ํ™” ๋„ฃ๋Š” ๋ฐฉ๋ฒ•
ANDROID 2020. 8. 2. 16:47

et_id = findViewById(R.id.et_id); // EditText btn_click = findViewById(R.id.btn_click); // Button (๋งŒ๋“  ๋ณ€์ˆ˜์— xml์˜ ์•„์ด๋””๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ์ž‘์—… / ์†์„ฑ๋ถ€์—ฌ) //click๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰๋˜๋Š” ๋ฉ”์†Œ๋“œ btn_click.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { et_id.setText("๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ๋‹ค!!!"); } }); click๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด EditText์˜ et_id์— "๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ๋‹ค!!!" ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค.

[์•ˆ๋“œ๋กœ์ด๋“œ]์•ฑ์— ์ด๋ฏธ์ง€ ๋„ฃ๋Š” ๋ฐฉ๋ฒ•(ImageView)
ANDROID 2020. 8. 2. 16:47

์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ์„ค์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค. app -> res -> drawable -> show in Explorer -> drowable ํด๋” ์•ˆ์— ์ด๋ฏธ์ง€ ๋ณต์‚ฌ ๊ทธ๋Ÿผ drawable์— ํ•ด๋‹น ์ด๋ฏธ์ง€๊ฐ€ ์ €์žฅ๋œ๋‹ค. ์ด๋ฏธ์ง€์˜ ์ด๋ฆ„์ด movie_image๋ผ๋ฉด ๊ฒฝ๋กœ๋Š” @drawable/movie_image์ด๋‹ค.

article thumbnail
[์•ˆ๋“œ๋กœ์ด๋“œ]์•ˆ๋“œ๋กœ์ด๋“œ TextView, EditText , Button ๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•
ANDROID 2020. 8. 2. 16:46

TextView ์‚ฌ์šฉ๋ฒ• 1,2. ๋ ˆ์ด์•„์›ƒ์ด ๊ฐ์‹ธ๋Š” ์ •๋„๋ฅผ ์ •๋„๋ฅผ ๊ฒฐ์ •ํ• ๋•Œ -wrap_content: ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋Š”๋ฐ์— ํ•„์š”ํ•œ ๊ธธ์ด๋งŒํผ๋งŒ์„ ๊ฐ์‹ผ๋‹ค. -match_parent: ๋ถ€๋ชจ๊ฐ€ ๊ฐ€์ง€๋Š” ํฌ๊ธฐ๋งŒํผ์„ ๊ฐ์‹ผ๋‹ค. (ํ•ด๋‹น ๋ ˆ์ด์•„์›ƒ์˜ ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ๋งŒํผ์„ ๊ฐ€๋“ ์ฑ„์šด๋‹ค) 3.๋ ˆ์ด์•„์›ƒ์•ˆ์˜ ํ…์ŠคํŠธ๋Š” My first application!์œผ๋กœ ์ ์–ด์ฃผ์—ˆ๋‹ค. 4.ํ…์ŠคํŠธ ์ปฌ๋Ÿฌ๋Š” ๋ณด๋ผ์ƒ‰์œผ๋กœ ํ•ด์ฃผ์—ˆ๊ณ  ๋”ฐ์˜ดํ‘œ์•ˆ์— #ffffff๋ฅผ ์ ์–ด์ฃผ๋ฉด ์ƒ‰์ƒ์„ ํƒํŒ์ด ๋œจ๊ฒŒ๋œ๋‹ค. ๊ทธ ์ƒ‰์ƒํŒ์—์„œ ์›ํ•˜๋Š” ์ƒ‰๊น”์„ ์„ ํƒํ•ด์ฃผ๋ฉด ์ž๋™์œผ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋œ๋‹ค. 5.๊ธ€์ž์˜ ํฌ๊ธฐ๋Š” 25sp๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. ํ…์ŠคํŠธ ํฌ๊ธฐ ๋‹จ์œ„๋Š” sp๋กœ ํ•œ๋‹ค. EditText ์‚ฌ์šฉ๋ฒ• 1. ์›ํ•˜๋Š” EditText๋ฅผ ๋งŒ๋“ค๋•Œ ๋™์ ์ธ ์•ก์…˜์„ ํ›„์— ๋งŒ๋“ค์–ด ์ฃผ๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น EditText์˜ id๋ฅผ ๋งŒ๋“ค..