<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Insert title here</title>

</head>

<body>

 

<%-- 

<%!   %> 선언문(자바 변수, 메소드 선언)

<%    %> 스크릿렛(자바 로직)

<%=   %> 표현(html 출력)

<%-- --> 주석

--%>

 

<% 

      for(int i=1; i<=5; i++) {

%>

 

      <p> 샘플 <%= i %></p>

     

<%

      }

%>   

 

 

</body>

</html>


File - Invalidate Caches / Restart - Invalidate and Restart 클릭

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_height="match_parent"
tools:context="com.example.jmj.atacadao.MainActivity">

</android.support.constraint.ConstraintLayout>
노란색으로 표시한 부분을 지운 뒤, LinearLayout을 적어준다.
<?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:layout_height="match_parent"
tools:context="com.example.jmj.atacadao.MainActivity">

</LinearLayout>


AndroidManifest.xml에 가서 android:theme=~~ 이 부분을 아래와 같이 수정한다.


android:theme="@style/Theme.AppCompat.NoActionBar"


(프로젝트명)\app\src\main\res\mipmap-hdpi

이 폴더에 이미지 넣기


이미지 이름은 첫 글자에 대문자나 숫자 X

소문자_소문자 이렇게 쓰는게 편할 듯 싶다

package com.example.jmj.tutorial3;

import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

   
private String[] items = {"망고", "딸기", "수박"};

   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView(R.layout.
activity_main);

        Button listButton = (Button) findViewById(R.id.
listButton);
        listButton.setOnClickListener(
new View.OnClickListener() {
           
@Override
               
public void onClick(View v){
                    AlertDialog.Builder builder =
new AlertDialog.Builder(MainActivity.this);
                    builder.setTitle(
"리스트");
                    builder.setItems(
items, new DialogInterface.OnClickListener() {
                       
@Override
                        
public void onClick(DialogInterface dialog, int i) {
                            Toast.makeText(getApplicationContext(),
items[i], Toast.LENGTH_SHORT).show();
                        }
                    });

                    AlertDialog alertDialog = builder.create();
                    alertDialog.show();
                }
        });

        Button exitButton  = (Button) findViewById(R.id.
exitButton); //ui에서 id 받아오기
       
exitButton.setOnClickListener(new View.OnClickListener(){
            
@Override
           
public void onClick(View v){
                AlertDialog.Builder builder =
new AlertDialog.Builder(MainActivity.this);
                builder.setMessage(
"종료 ?");
                builder.setTitle(
"종료 알림창")
                        .setCancelable(
false) //3자가 건드리지 못하게 함
                       
.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
                           
@Override
                           
public void onClick(DialogInterface dialog, int i){
                                finish();
                            }
                        })
                        .setNegativeButton(
"No", new DialogInterface.OnClickListener(){
                       
@Override
                       
public void onClick(DialogInterface dialog, int i){
                            dialog.cancel();
                        }
                    });
                AlertDialog alert = builder.create();
                alert.setTitle(
"종료 알림창");
                alert.show();
            }
        });
    }
}

 





출처 : https://www.inflearn.com/course/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%8A%A4%ED%8A%9C%EB%94%94%EC%98%A4-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%95%B1-%EB%A7%8C%EB%93%A4%EA%B8%B0/#course-curriculum


참고 사이트 : http://wanna-b.tistory.com/42


File - Settings... - Build, Execution, Deployment - Instant Run - Uncheck : Enable Instant Run

shift + F6 변수명 한번에 변경!

클래스명 바꿀 때도 사용 가능->관련 변수도 자동 변경됨!



match_parent 부모 뷰그룹에 크기 맞추기/버튼은 부모 뷰그룹 너비만큼

wrap_content 뷰 스스로 적당한 크기 맞추기/버튼의 경우 텍스트라벨의 너비만큼





To solve this problem, erase forder /.gradle and reopen Android stuido.



컴퓨터 성능이 안좋아서인지는 모르겠지만, 안드로이드 스튜디오를 설치해서 에뮬레이터 돌리기 까지가 너무 험난하다.

며칠 째 안되고 있는 중이라서 지식인이랑 카페에 질문하면서 수정해가는 중이다.

참 뭔가를 세팅할 때마다 시간 많이 잡아먹는 것 같다.


프로젝트를 삭제한 다음에 안드로이드 스튜디오를 껐다가 다시 시작하라고 한다. 


해봤는데 해결이 안 된다.






If you didn't solve this problem, then select File - Invalidate Cashes / Restart.. and Invalidate and Restart


위 사진같이 클릭해보는 방법도 있다고 한다.

하지만 역시 안된다.





Or close all projects(File - Close Project), and create a new project.


다음은 모든 프로젝트를 File - Close Project를 통해서 닫고

프로젝트 이름을 바꿔서 새로운 프로젝트로 실행시키는 방법이다.


이렇게 하니깐 Activity 설정하는데에서 더 넘어가지 않고 막혀버렸다.



프로그램을 지우고 차근차근 다시 깔아봐야겠다.




+ Recent posts