사용한 툴 : 이클립스

사용 버전 : API 16

첨부 파일 : AndImageViewer.zip



MainActivity.java

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.andimageviewer;
 
import java.io.File;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
 
public class MainActivity extends Activity {
    Button btnPre,btnNext;
    myPictureView myPicture;
    int curNum;
    File[] imageFiles;
    String imageFname;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setTitle("간단 이미지 뷰어");
        
        btnPre=(Button)findViewById(R.id.btnPrev);
        btnNext=(Button)findViewById(R.id.btnNext);
        myPicture=(myPictureView)findViewById(R.id.myPictureView1);
        
        imageFiles = new File("/sdcard/pictures").listFiles();
        imageFname = imageFiles[0].toString();
        myPicture.imagePath = imageFname;
        
        btnPre.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                if(curNum <=0)
                {
                    Toast.makeText(getApplicationContext(), "첫번째 그림입니다.", Toast.LENGTH_SHORT).show();
                }else{
                    curNum--;
                    setMyPicture();
                }
            }
        });
        btnNext.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                if(curNum>=imageFiles.length-1)
                {
                    Toast.makeText(getApplicationContext(), "마지막 그림입니다.", Toast.LENGTH_SHORT).show();
                }
                else{
                    curNum++;
                    setMyPicture();
                }
            }
        });
    }
    private void setMyPicture()
    {
        imageFname=imageFiles[curNum].toString();
        myPicture.imagePath = imageFname;
        myPicture.invalidate();
    }
}
 
 
cs


myPictureView.java

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
package com.andimageviewer;
 
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
 
public class myPictureView extends View {
    String imagePath = null;
    public myPictureView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }
 
    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        if(imagePath != null)
        {
            Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
            canvas.drawBitmap(bitmap, 00,null);
            bitmap.recycle();
        }
    }
    
}
 
cs


activity_main.xml

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.andimageviewer.MainActivity" >
 
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <Button 
            android:id = "@+id/btnPrev"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="이전 그림"/>
        <Button 
            android:id = "@+id/btnNext"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="다음 그림"/>
    </LinearLayout>
    <com.andimageviewer.myPictureView 
        android:id="@+id/myPictureView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>
 
cs


sdcard/Picture파일에 있는 이미지 파일을 가져와 보여주는 Simple Application

가상머신에서 구동시 DDMS로 (안드로이드 스튜디오는 Android Device Monitor를 이용) sdcard/Picture 폴더에 이미지를 넣어 실행하면 된다.


AndImageViewer.zip


  1. 안드로이드 스튜디오의 첫화면에서 Import project (Eclipse ADT, cradle, etc.) 을 선택한다
  2. import할 프로젝트의 폴더를 선택한다.
  3. 변환한 프로젝트를 저장할 경로를 선택한다.
  4. 완료



사용한 툴 : 이클립스

사용 버전 : API 16

첨부 파일 : AndSDcardTest.zip


먼저 컴퓨터 내에 AVD로 할 경우 AVD의 SDCard의 용량을 지정해주어야 한다. (실제 용량을 차지하므로 주의)


▲ 설정후 확인버튼을 해주면 된다.


SD카드를 사용하려면 AndroidManifest.xml에서 퍼미션을 지정해주어야 한다.

AndroidManifest.xml

1
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
cs

AndroidManifest에 application 위에 기재하면 된다.


activity_main.xml

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.andsdcardtest.MainActivity"
    android:orientation="vertical" >
    <Button
        android:id="@+id/btnRead"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="읽기"
        />
    <EditText 
        android:id = "@+id/edtSD"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:lines="10"/>
</LinearLayout>
cs




MainActivity.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
package com.andsdcardtest;
 
import java.io.FileInputStream;
import java.io.IOException;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
 
public class MainActivity extends Activity {
    Button btnRead;
    EditText edtSd;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setContentView(R.layout.activity_main);
        btnRead=(Button)findViewById(R.id.btnRead);
        edtSd = (EditText)findViewById(R.id.edtSD);
        
        btnRead.setOnClickListener(new OnClickListener() {        
            @Override
            public void onClick(View v) {
                try {
                    FileInputStream infs= new FileInputStream("/sdcard/file.txt");
                    byte[] temp =new byte[infs.available()];
                    infs.read(temp);
                    infs.close();
                    edtSd.setText(new String(temp));
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                
            }
        });
    }
 
}
 
cs


AndSDcardTest.zip


사용한 툴 : 이클립스

사용 버전 : API 16

첨푸 파일 : AndRawTest.zip



안드로이드 프로젝트의 /res/raw 폴더에 필요한 파일을 저장해서 사용하는 방법도 있다. 단 쓰기는 되지않고 읽기만 가능하다.

이 때는 FileInputStream 클래스 대신 InputStream 클래스를 사용하면 된다.

처음 프로젝트를 생성하면 폴더가 안보이는데 개발자가 /res에 raw폴더를 생성해주면 된다. 


▲프로젝트 내에 폴더 생성하는 방법




activity_main.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.andrawtest.MainActivity"
    android:orientation="vertical" >
 
    <Button
        android:id = "@+id/btnRead"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="읽기"/>
    <EditText 
        android:id = "@+id/edtRaw"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:lines="10"/>
    
</LinearLayout>
 
cs


MainActivity.java

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
package com.example.andrawtest;
 
import java.io.IOException;
import java.io.InputStream;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
 
public class MainActivity extends Activity {
    Button btnRead;
    EditText edtRaw;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnRead=(Button)findViewById(R.id.btnRead);
        edtRaw = (EditText)findViewById(R.id.edtRaw);
        
        btnRead.setOnClickListener(new OnClickListener() {        
            @Override
            public void onClick(View v) {
                InputStream inputS = getResources().openRawResource(R.raw.file);
                try {
                    byte[] temp =new byte[inputS.available()];
                    inputS.read(temp);
                    inputS.close();
                    edtRaw.setText(new String(temp));
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                
            }
        });
    }
}
 
cs


29 먼저 리소스를 얻고 거기서 Raw리소스를 얻어오는 형식으로 파일을 가져온다.

31 temp를 파일크기만큼의 배열을 생성한다.

34 edtRaw에 temp를 넣기위해 String형태로 변환해준다. 안보이는데 개발자가 /res에 raw폴더를 생성해주면 된다.


AndRawTest.zip


안드로이드 내부 메모리 파일 처리
사용한 툴 : 이클립스
사용한 버전 : API 16
첨부 파일 : AndFileTest.zip

 


내장 메모리의 저장 위치는 /data/data/패키지명/files 폴더에 저장된다.

저번 포스팅에서 자바는 스트림 형태(바이트형태)로 파일을 읽고 쓰기 때문에 FIleInputStream, FileOutputStream 클래스가 사용한다.

내장 메모리의 파일을 읽을 때 openFileInput(파일명); 메소드를 사용하고 Read메소드로 값을 읽는다.

파일을 쓸 때는 openFileOutput(파일명, 모드명); 메소드로 파일을 지정하고 Write메소드로 값을 출력한다.

openFileOutput은 추가적으로 모드를 설정해야하는데, 모드들은 다음과 같다.

Context.MODE_WORLD_WRITEABLE : 쓰기

Context.MODE_WORLD_READABLE : 읽기

Context.MODE_APPEND : 기존 파일에 추가

Context.MODE_PRIVATE : 개인

사용한 스트림 파일은 close로 닫아줘야 한다.



activity_main.xml

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.filetest.MainActivity" 
    android:orientation="vertical">
    <Button
        android:id="@+id/btnRead"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="읽기"
        />
    <Button
        android:id="@+id/btnWrite"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="쓰기"/>
</LinearLayout>
cs



MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.example.filetest;
 
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
 
public class MainActivity extends Activity {
    Button btnRead,btnWrite;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnRead = (Button) findViewById(R.id.btnRead);
        btnWrite = (Button) findViewById(R.id.btnWrite);
        btnRead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                try {
                    FileInputStream infs = openFileInput("File.txt"); //파일이 없으면 FileNotFoundException예외
                    byte[] temp = new byte[infs.available()]; //파일길이 측정하다가 예외가 발생하면 IOException예외발새
                    infs.read(temp);
                    String strData = new String(temp);
                    Toast.makeText(getApplicationContext(),strData,Toast.LENGTH_SHORT).show();
                    infs.close();
                } catch (FileNotFoundException e) {
                    Toast.makeText(getApplicationContext(),"not file exist." , Toast.LENGTH_SHORT).show();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        btnWrite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    FileOutputStream outfs = openFileOutput("File.txt", Context.MODE_WORLD_WRITEABLE);
                    String strTemp = "Java and Andriod!";
                    outfs.write(strTemp.getBytes());
                    outfs.close();
                    Toast.makeText(getApplicationContext(),"make File!",Toast.LENGTH_SHORT).show();
                }catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
 
cs

 


23 ~ 29 '읽기' 버튼을 눌렀을 때 파일을 읽어들여 토스트에 띄우는 온클릭리스너 등록

28 파일의 사이즈를 측정하여 그 사이즈만큼 바이트 배열을 지정한다.

30 읽은 값이 byte형태이기 때문에 String형태로 변환한다.

40 ~ 53 '쓰기' 버튼을 눌렀을 때 파일을 만드는 온클릭리스너 등록. 만들때 같은 이름이 있어도 덮어씌운다.


AndFileTest.zip



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
public class ByteStreamSample {
 
    public static void main(String[] args) throws IOException {
        FileInputStream in = null;
        FileOutputStream out = null;
        File inFileName = new File("dog.jpg");
        String fileName = "dog";
        String newName;
 
        for (int i=1;;i++) {
            int data = 0;
            try {
                newName = fileName+String.valueOf(i)+".jpg";
                File inFile=new File(newName);
                if(inFile.exists())
                {
                    System.out.println("FileName is exist.");
                    continue;
                }
                in = new FileInputStream(inFileName);
                out = new FileOutputStream(inFile);
 
                while (data != -1) {
                    data = in.read();
                    out.write(data);
                }
 
                System.out.println(newName + "File Copy");
 
            } catch (FileNotFoundException e) {
                System.out.println(fileName + "File not exist. Program quit");
                break;
            }
 
            in.close();
            out.close();
        }
    }
 
}
 
 
cs

 

프로젝트 내에 dog.jpg 파일을 dog1, dog2, ... 뒤에 넘버를 붙이면서 복제하는 프로그램.

같은 파일 이름이 존재하는지 검사 한뒤 이미 파일이 있다면 다음 숫자로 넘긴다.

파일이름이 없다면 그 파일이름으로 dog.jpg파일을 복사한뒤 다음 숫자로 넘어간다.


중간에 나가는 설정이 없으므로 이 프로젝트를 실행한 뒤에 어느정도 시간이 지나면 강제로 중단하길 바란다.

제네릭 타입 : 타입을 파라미터로 가지는 클래스와 인터페이스. 선언시 클래스 또는 인터페이스 이름 뒤에 '< >' 부호 붙임. 일반적으로 대문자 한글자만 적는다.


장점

실행시 타입에러가 나는 것을 방지한다.

컴파일 시에 미리 타입을 강하게 체크해서 에러를 방지한다.

타입캐스트시 생기는 속도저하를 없앤다.

 

ArrayList에 저장되는 형태는 Object형태로 들어간다.
1
2
3
4
5
6
7
        List list = new ArrayList();
        list.add("hello");
        list.add("hi");
        strTemp = (String)list.get(0);
        System.out.println(strTemp);
        strTemp = (String)list.get(1);
        System.out.println(strTemp);
cs

이럴 경우 값을 얻을 때 타입케스팅을 명확히 해야하고 시간이 오래 걸린다.


 

1
2
3
4
        List<String> strList = new ArrayList();
        strList.add("hi");
        strTemp = strList.get(0);
        System.out.println(strTemp);
cs

리스트를 만들 때 제네릭을 이용하여 형을 정해주면 타입케스팅을 하지 않아도 되서 시간이 적게 걸린다.


제네릭을 클래스에도 적용할 수 있다.

Box 클래스

 

1
2
3
4
5
6
public class Box<T> {
    private T obj;
    public void set(T obj) {this.obj=obj;}
    public T get() {return obj;}
}
 
cs

 

 

메인문 내부

 

1
2
3
4
Box<String> box = new Box<String>();
box.set("test");
strTemp = box.get();
System.out.println(strTemp);
cs

 

T부분이 String로 변환되는 예제


제네릭은 여러 개 사용할 수 있다.

 

1
2
3
4
5
6
7
8
9
10
public class Product<T, M> {
    private T kind;
    private M model;
    
    public void setKind(T kind) {this.kind=kind;}
    public void setModel(M model) {this.model=model;}
    
    public T getKind(){return kind;}
    public M getModel(){return model;}
}
cs


제네릭을 메소드에도 적용할 수 있다. 메소드에 적용할 땐 반환타입 앞에 제네릭을 선언하면 된다.

public <T> Box<T> boxing(T t);


 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Util {
    public static <T> Box<T> boxing(T t){ 
        Box<T> box = new Box<T>();
        box.set(t);
        return box;
    }
    
    public static <T> boolean setData(T t){ 
        return true;
    }
    
    public static <K,V> boolean compare(Pair<K,V> p1, Pair<K,V> p2)
    {
        boolean keyCompare = p1.getKey().equals(p2.getKey());
        boolean valueCompare = p1.getValue().equals(p2.getValue());
        return keyCompare && valueCompare;
    }
}
cs


 

1
boolean result1 = Util.<Integer,String>compare(p1, p2);
cs

메소드를 사용할 때 제네릭을 명시적으로 선언해도 매개변수에 제네릭을 사용할 경우 묵시적으로 설정한다.


자바 I/O 시스템은 스트림(stream)으로 구성되어 있다.

스트림은 데이터 흐름의 추상적 개념으로 입력 스트림(input stream)은 프로그램으로의 데이터 흐름이며(파일->프로그램),

출력 스트림은(output stream)은 프로그램으로부터 나오는 데이터의 흐름을 나타낸다(프로그램->파일).


자바에서의 스트림의 형태는 바이트 스트림 클래스와 문자 스트림 클래스 두 종류가 있다.

바이트 스트림 클래스는 InputStream, OutputStream으로 입출력을 사용하고 

문자 스트림 클래스는 Reader, Writer로 입출력을 한다.


 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.*;
 
public class FileCopy {
 
    public static void main(String[] args) throws IOException {
        File input = new File("/Users/ghdrl95/Documents/input.txt");
        File output = new File("/Users/ghdrl95/Documents/output.txt");
        
        FileInputStream in = new FileInputStream(input);
        FileOutputStream out = new FileOutputStream(output);
        
        int cTemp;
        
        while((cTemp = in.read()) != -1){
            out.write(cTemp);
        }
    }
 
}
 
cs

바이트 스트림 중 하나인 File(In,Out)putStream 이다.

File 클래스를이용해 파일의 경로를 입력하고 그것을 파일스트림에게 준다.

그리고 read()메소드를 통해 한글자씩 받아 write메소드를 통해 출력한다.

경로를 적지 않으면 프로젝트가 생성된 곳에 파일이 생성, 입력되며 파일이 없는 경우 IOexception이 발생한다.


EditText에 적힌 주소로 WebView가 접속하여 출력해주는 간단한 어플리케이션

앞에 http://를 적지 않아도 실행 되도록 설정.


MainActivity.java

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.webbrower;
 
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
 
public class MainActivity extends AppCompatActivity {
    EditText edtUrl;
    Button btnGo, btnBack;
    WebView web;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        edtUrl = (EditText)findViewById(R.id.edtUrl);
        btnGo = (Button) findViewById(R.id.btnGo);
        btnBack = (Button) findViewById(R.id.btnBack);
        web = (WebView) findViewById(R.id.webView1);
 
        web.setWebViewClient(new CookWebViewClient());
 
        WebSettings webSet = web.getSettings();
        webSet.setBuiltInZoomControls(true);
 
        btnGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String strTemp = edtUrl.getText().toString();
                if(!strTemp.substring(0,7).equals("http://")){
                    strTemp= "http://"+strTemp;
                }
                web.loadUrl(strTemp);
 
            }
        });
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                web.goBack();
            }
        });
    }
    public class CookWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return super.shouldOverrideUrlLoading(view, url);
        }
    }
 
}
 
 
cs


AndroidManifest.xml 에서

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
를 명시해주어야 어플내에 인터넷을 사용할 수 있다.
activity_main.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:orientation="vertical"
    tools:context=".MainActivity"
    >
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/edtUrl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true"/>
        <Button
            android:id="@+id/btnGo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="이동"/>
        <Button
            android:id="@+id/btnBack"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="이전"/>
    </LinearLayout>
    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
 
    </WebView>
</LinearLayout>
 
 
cs
 

WebBrower.zip




어플리케이션에서 아에 사용하지 않을 거라면

AndroidManifest.xml 에서 android:theme을

android:theme="@android:style/Theme.NoTitlBar" 로 수정하면 된다.


특정화면에서만 타이틀을 제거 할 때는

onCrate 메소드 안에 

requestWindowFeature(Window.FEATURE_NO_TITLE);

를 입력하면 된다.

+ Recent posts