xmlns:android="http://schemas.android.com/apk/res/android"


xmlns:[접두어]="문법 정의 URI"

접두어는 android:로 시작할 필요없다. 


스키마 URI의미


schemas.android.com  안드로이드 스키마

/apk/res  앱의 리소스

/android  패키지명


안드로이드 스키마는 android라는 패키지명의 앱 리소스를 참조한다는 것이다.

뒤에 패키지명만 달리하면 다른앱의 리소스에 존재하는 문법도 사용할 수 있다.


android 패키지는 안드로이드 플래폼을 말한다. 정확한 안드로이드 스키마 파일은 안드로이드 플랫폼 전체 소스 내의 다음 위치에 있다.


framework/base/core/res/res/values/attrs.xml (플랫폼의 리소스 폴더에 존재)



블로그 이미지

왕왕왕왕

,

layout_marginLeft 뷰의 좌측에 여백을 준다.

layout_marginRight 뷰의 우측에 여백을 준다.

layout_marginTop 뷰의 상단에 여백을 준다.

layout_marginBottom 뷰의 하단에 여백을 준다.

layout_margin 뷰의 상/하/좌/우 여백을 동일하게 준다.



블로그 이미지

왕왕왕왕

,

layout_width 뷰의 너비설정(픽셀이나 dp 등의 단위로 입력가능)

layout_height 뷰의 높이 설정(픽셀이나 dp 등의 단위로 입력가능)




layout_width,layout_height 속성값에는 수치 단위가 아닌 wrap_content와 match_parent두가지 값을 설정할 수도 있다.




wrap_content 뷰스스로 적당한 크기에 맞추라는 의미다. 버튼뷰의 경우 버튼에 쓰여진 텍스트가 표현될 수 있는 최소 크기만큼 너비가 자동으로 지정된다.


match_parent 부모 뷰그룹의 크기에 맞추라는 의미다. 버튼뷰의 경우 부모 뷰그룹의 너비만큼 지정된다.




블로그 이미지

왕왕왕왕

,

주소링크

http://developer.android.com/sdk/installing/installing-adt.html















이런오류가 날 수 있다.

emulator: WARNING: Requested RAM size of 2048MB is too large for your environment, and is reduced to 1536MB.

RAM : 768M로 바까주면된다.


블로그 이미지

왕왕왕왕

,

<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"

    android:orientation="vertical"

    tools:context=".MainActivity" >

 

    <EditText

        android:id="@+id/address"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:hint="Address" />

    <EditText

        android:id="@+id/port"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:hint="Port" />

    <Button

        android:id="@+id/connect"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="Connect..."/>

    <Button

        android:id="@+id/clear"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="Clear"/>

    <TextView

        android:id="@+id/response"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"/>

 

</LinearLayout>

블로그 이미지

왕왕왕왕

,

package javaServer;


import java.io.BufferedReader;

import java.io.IOException;

import java.io.OutputStream;

import java.io.PrintStream;

import java.io.PrintWriter;

import java.net.ServerSocket;

import java.net.Socket;


class Server {


public static void main(String[] args) {


System.out.println("S: Connecting...");

try {

ServerSocket serverSocket = new ServerSocket(5555);

while (true) {

Socket client = serverSocket.accept();

Thread desktopServerThread = new Thread(new startThread(client));

desktopServerThread.start();

}

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}


}


static class startThread implements Runnable {

Socket socket = null;

PrintWriter out = null;

BufferedReader in = null;

public startThread(Socket client) {

// TODO Auto-generated constructor stub

this.socket = client;

}


@Override

public void run() {

// TODO Auto-generated method stub


System.out.println("from " + socket.getInetAddress() + ":" + socket.getPort());


OutputStream outputStream;

try {

outputStream = socket.getOutputStream();

PrintStream printStream = new PrintStream(outputStream);

printStream.print("Server Send data ~~ ");

printStream.close();


socket.close();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}

}



블로그 이미지

왕왕왕왕

,

package com.example.at;

 

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.net.Socket;

import java.net.UnknownHostException;

 

import android.app.Activity;

import android.os.AsyncTask;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

 

public class MainActivity extends Activity {

 

    private TextView txtResponse;

    private EditText edtTextAddress, edtTextPort;

    private Button btnConnect, btnClear;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

 

        edtTextAddress = (EditText) findViewById(R.id.address);

        edtTextPort = (EditText) findViewById(R.id.port);

        btnConnect = (Button) findViewById(R.id.connect);

        btnClear = (Button) findViewById(R.id.clear);

        txtResponse = (TextView) findViewById(R.id.response);

 

        btnConnect.setOnClickListener(buttonConnectOnClickListener);

        btnClear.setOnClickListener(new OnClickListener() {

 

            public void onClick(View v) {

                txtResponse.setText("");

            }

        });

    }

     

    // 클릭이벤트 리스너 

    OnClickListener buttonConnectOnClickListener = new OnClickListener() {

 

        public void onClick(View arg0) {

            NetworkTask myClientTask = new NetworkTask(

                    edtTextAddress.getText().toString(), 

                    Integer.parseInt(edtTextPort.getText().toString())

            );

            myClientTask.execute();

        }

    };

 

    public class NetworkTask extends AsyncTask<Void, Void, Void> {

 

        String dstAddress;

        int dstPort;

        String response;

 

        NetworkTask(String addr, int port) {

            dstAddress = addr;

            dstPort = port;

        }

 

        @Override

        protected Void doInBackground(Void... arg0) {

 

            try {

                Socket socket = new Socket(dstAddress, dstPort);

                InputStream inputStream = socket.getInputStream();

                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(

                        1024);

                byte[] buffer = new byte[1024];

 

                int bytesRead;

                while ((bytesRead = inputStream.read(buffer)) != -1) {

                    byteArrayOutputStream.write(buffer, 0, bytesRead);

                }

               

                socket.close();

               

                response = byteArrayOutputStream.toString("UTF-8");

            } catch (UnknownHostException e) {

                e.printStackTrace();

            } catch (IOException e) {

                e.printStackTrace();

            }

            return null;

        }

 

        @Override

        protected void onPostExecute(Void result) {

            txtResponse.setText(response);

            super.onPostExecute(result);

        }

 

    }

}

블로그 이미지

왕왕왕왕

,

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.school);


WebView wb = (WebView) findViewById(R.id.webView1);

WebSettings settings = wb.getSettings();

wb.getSettings().setJavaScriptEnabled(true); //자바 스크립스 사용

wb.setWebViewClient(new WebViewClient()); 

wb.setInitialScale(50); //배율설정

wb.getSettings().setBuiltInZoomControls(true); //줌기능추가

wb.loadUrl("http://www.seowon.ac.kr/web/kor/seowon_a_01");

}

public boolean onKeyDown(int keyCode, KeyEvent event) {

 // TODO Auto-generated method stub

WebView wb = (WebView) findViewById(R.id.webView1);

 if ((keyCode == KeyEvent.KEYCODE_BACK) && wb.canGoBack()) 

 {              

  wb.goBack();         

  

  return true;

 } 

 

 return super.onKeyDown(keyCode, event);

}


}

블로그 이미지

왕왕왕왕

,