반응형





이보게 젊은이 광고 한번만 클릭함해주시게..





반응형

'Life > ' 카테고리의 다른 글

죠스 장난감  (0) 2011.08.16
예능 데스크  (0) 2011.08.16
아놔 이런 ....  (0) 2011.08.15
독도는 우리땅입니다.  (0) 2011.08.06
싸이월드 네이트 한껀하다!!  (0) 2011.07.31
네이트 해킹  (0) 2011.07.29
페이스북 가입일 알아보기  (0) 2011.07.28
[WOW] Paragon, 라그나로스 25인 하드영상!  (0) 2011.07.28
반응형

컴퍼넌트의 크기를 지정

컴퍼넌트란!  걍 만들어진 class 라고 보면됨


params
: 파라미터는 레이아웃의 종류마다 다르다

LinearLayout을 이용할 경우에는 LinearLayout.LayoutParams클래스를 사용한다





반응형
반응형
토스트는 잢은 시간동안 메ㅅㅣ지를 화면에 표시할수 있는 기능!


static Tosast makeText(Context context,int resld, int duration

resID 리소스아이디

duration 표시시간!
반환값 Toast 객체 


반응형
반응형
package net.npaka.socketex;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

//소켓 통신
public class SocketEx extends Activity
implements View.OnClickListener {
private final static String BR=//개행
System.getProperty("line.separator");
private final static String IP=//IP 주소 지정 (1)
//"127.0.0.1";
"192.168.0.201";
private SocketEx current; //현재
private TextView lblReceive;//수신 라벨
private EditText edtSend; //송신 텍스트 박스
private Button btnSend; //송신 버튼
private Socket socket; //소켓
private InputStream in; //입력 스트림
private OutputStream out; //출력 스트림
private final Handler handler=new Handler();//핸들러 (6)
private String txtReceive;//수신 텍스트
//초기화
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
current=this;
//레이아웃의 생성 (8)
RelativeLayout layout=new RelativeLayout(this);
layout.setBackgroundColor(Color.rgb(255,255,255));
setContentView(layout);
//수신 라벨의 생성
lblReceive=new TextView(this);
lblReceive.setId(1);// (9)
lblReceive.setText("");
lblReceive.setTextSize(16.0f);
lblReceive.setTextColor(Color.rgb(0,0,0));
RelativeLayout.LayoutParams param1=// (9)
new RelativeLayout.LayoutParams(320,400);
lblReceive.setLayoutParams(param1);
layout.addView(lblReceive);
//송신 텍스트 박스의 생성
edtSend=new EditText(this);
edtSend.setId(2);// (9)
edtSend.setText("",TextView.BufferType.NORMAL);
RelativeLayout.LayoutParams param2=// (9)
new RelativeLayout.LayoutParams(200,50);
param2.addRule(RelativeLayout.BELOW,1);
edtSend.setLayoutParams(param2);
layout.addView(edtSend);
//송신 버튼의 생성
btnSend=new Button(this);
btnSend.setText("송신");
btnSend.setOnClickListener(this);
RelativeLayout.LayoutParams param3=// (9)
new RelativeLayout.LayoutParams(200,50);
param3.addRule(RelativeLayout.BELOW,1);
param3.addRule(RelativeLayout.RIGHT_OF,2);
btnSend.setLayoutParams(param3);
layout.addView(btnSend);
//스레드 생성 (2)
(new Thread(){public void run() {
try {
connect(IP,8080);
} catch (Exception e) {
}
}}).start();
}
//접속
private void connect(String ip,int port) {
int size;
byte[] w=new byte[1024];
txtReceive="";
try {
//소켓 접속 (3)
socket=new Socket(ip,port);
in =socket.getInputStream();
out=socket.getOutputStream();
//수신 반복 루프 (4)
while (socket!=null && socket.isConnected()) {
//데이터 수신 (5)
size=in.read(w);
if (size<=0) continue;
txtReceive=new String(w,0,size,"UTF-8");
//핸들러에 의한 사용자 인터페이스 조작 (6)
handler.post(new Runnable(){
public void run() {
//라벨의 문자열 추가
lblReceive.setText(
lblReceive.getText()+txtReceive+BR);
}
});
}
} catch (Exception e) {
handler.post(new Runnable(){
public void run() {
SocketEx.showDialog(current,"","통신 에러입니다 .");
}
});
}
}
//버튼 클릭 이벤트 처리
public void onClick(View v) {
if (v==btnSend) {
try {
//데이터 송신 (7)
if (socket!=null && socket.isConnected()) {
byte[] w=edtSend.getText().toString().getBytes("UTF8");
out.write(w);
out.flush();
edtSend.setText("",TextView.BufferType.NORMAL);
}
} catch (Exception e) {
handler.post(new Runnable(){
public void run() {
SocketEx.showDialog(current,"","통신 에러입니다 .");
}
});
}
}
}
//대화상자 표시
public static void showDialog(final Activity activity,String title,String text) {
AlertDialog.Builder ad=new AlertDialog.Builder(activity);
ad.setTitle(title);
ad.setMessage(text);
ad.setPositiveButton("OK",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton) {
activity.setResult(Activity.RESULT_OK);
}
});
ad.create();
ad.show();
}
}
반응형
반응형
package test.test;

import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.view.*;

public class mainA extends View {
   
    private static Bitmap mainimg;
   
    private static Bitmap newg;
    private static Bitmap cont;
    private static Bitmap lan;
    private static Bitmap qit;
   
   
    public mainA(Context context) {
        super(context);
        setBackgroundColor(Color.WHITE);
       
        Resources r= context.getResources();
        //image =BitmapFactory.decodeResource(r,R.drawable.a);
       
        mainimg =BitmapFactory.decodeResource(r,R.drawable.mainimgpng);
       
        newg =BitmapFactory.decodeResource(r,R.drawable.newgame);
        cont =BitmapFactory.decodeResource(r,R.drawable.cont);
        lan =BitmapFactory.decodeResource(r,R.drawable.lan);
        qit =BitmapFactory.decodeResource(r,R.drawable.quit);
       
       
       
       
       
       
        // TODO Auto-generated constructor stub
    }

   
    Paint p=new Paint();
   
   
    protected void onDraw(Canvas canvas) {
        int w= mainimg.getWidth();
        int h=mainimg.getHeight();
   
       
        Rect src =new Rect(0,0,w,h);
        Rect dst =new Rect(0,0,getWidth(),getHeight());
       
               
        canvas.drawBitmap(mainimg, src,dst, null);
       
        ///////////////////
       
    /*    int newgw= newg.getWidth();
        int newgh=newg.getHeight();
        Rect newgsrc =new Rect(0,0,w,h);
        Rect newgdst =new Rect(0,0,getWidth(),getHeight());*/
        /*Rect gnesrc =new Rect(0,0,0,0);
        Rect gnewdst =new Rect(0,0,0,0);*/
        //canvas.drawBitmap(newg, gnesrc,gnewdst, null);
        /*       
         *
         */
        int statgw=(getWidth()/2)+(getWidth()/5);
       
        int statgh=(getHeight()/2)-(getHeight()/2);
        canvas.drawBitmap(newg,statgw,statgh, null);
        canvas.drawBitmap(cont,statgw,statgh+60, null);
        canvas.drawBitmap(lan,statgw,statgh+120, null);
        canvas.drawBitmap(qit,statgw,statgh+180, null);
       
       
       
        // TODO Auto-generated method stub
        super.onDraw(canvas);
    }

}




반응형
반응형




옵티머스Z

-ㅂ-후훗 이것으로 컴파일해서 돌려볼수 있게 되었슴.!!

부팅시 로딩이 기네요 ....

오래쓰면 ..알아서 재부팅하네요 [...]





반응형
반응형




package test.ImageEX;
import android.*;
import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.view.*;


public class ImageView  extends View{
    private Bitmap image;
    public ImageView(Context context) {
        super(context);
        setBackgroundColor(Color.WHITE);
        // TODO Auto-generated constructor stub
       
        Resources r= context.getResources();
        image =BitmapFactory.decodeResource(r,R.drawable.sample);
       
       
       
    }
   
    static int count1=0;
    Paint p=new Paint();
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
       
        //image ++
       
        canvas.drawText("WIND : "+count1,180,20,p);
        count1++;
       
       
       
        int w= image.getWidth();
        int h=image.getHeight();
        canvas.drawBitmap(image, 0,0, null);
       
       
        Rect src =new Rect(0,0,w,h);
        Rect dst =new Rect(0,200,w*2,200+h*2);
       
        canvas.drawBitmap(image, src,dst, null);
       
       
       
       
       
       
       
        src =new Rect(0,0,w,h);
        dst =new Rect(0,200,w/2,200+h/2);
        canvas.drawBitmap(image, src,dst, null);
       
       
       
       
        super.onDraw(canvas);
       
    }
   
   

}

반응형
반응형

안드로이드에서 풀스크린 만들기


getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);




반응형

+ Recent posts