'안드로이드'에 해당되는 글 57건

  1. 2011.05.30 Android - Hybrid app, Webview에서 html load시 java script 동작 안할 시
  2. 2011.05.27 Android - Listview divider / Listview gap space
  3. 2011.05.27 Android - view set margin in code
  4. 2011.05.27 Android - Bitmap resize
  5. 2011.05.25 Android - 리소스 xml coding시 단위
  6. 2011.05.19 Android - Create Option
  7. 2011.05.16 Android - Webview에서 loadData할시 페이지를 찾을수 없습니다 나올때..
  8. 2011.05.13 Android - Activity간 데이터 주고 받기
  9. 2011.05.13 Android - read textfile in sdcard
  10. 2011.05.13 Android - Bitmap 리소스, sdcard 이미지 load
  11. 2011.05.13 Android - Bitmap, Drawable convert
  12. 2011.05.04 Android - 디바이스의 가로, 세로 가져오기
  13. 2011.04.25 Android - 화면 가로, 세로 이벤트 및 현제 화면상태 확인
  14. 2011.04.18 Android - 타이틀바, 위쪽 상태표시창 제거하기 및 풀스크린
  15. 2011.04.14 Android - WebView auto fit
  16. 2011.04.14 Android - WebView Scroll Disable
  17. 2011.04.11 Android - Appspresso 시작하기 in Eclipse
  18. 2011.04.05 Android - VideoView 실시간 동영상
  19. 2011.03.31 Android - EditText 사용 시 키보드 Show/Hide
  20. 2011.03.30 Android - 암시적 Intent 사용 (전화걸기, 메일보내기, 사용자응용사용하기...)
  21. 2011.02.28 Android - width, height 가져오기
  22. 2011.02.16 Android - 동적으로 layout width, height 변경하기
  23. 2011.02.11 Android - WebView Zoom In/out 시 자동개행 설정
  24. 2011.02.11 Android - WebView Scale Control/Webview 비율로 넓이 조절
  25. 2011.02.11 Android - Text 줄 개행 양끝정렬
  26. 2011.01.20 Android - TextView 단어 단위로 개행 줄바꿈 하기 1
  27. 2011.01.06 Android - 문자열 자르기 StringTokenizer
posted by Full-stack Developer 2011. 5. 30. 18:54

WebView child = new WebView(this);
child.loadUrl("your_html_file.html");
child.getSettings().setJavaScriptEnabled(true);

true is working.
false is done.
posted by Full-stack Developer 2011. 5. 27. 16:03

ListView contents = new ListView(ctx);
  LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(300, LayoutParams.FILL_PARENT);
  lp.setMargins(2, 50, 0, 2);
  contents.setLayoutParams(lp);
  contents.setDivider(new ColorDrawable(Color.GRAY));
  contents.setDividerHeight(1);
posted by Full-stack Developer 2011. 5. 27. 15:23

LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
lp.setMargins(left, top, right, bottom); 
view
.setLayoutParams(lp);
posted by Full-stack Developer 2011. 5. 27. 09:39

Bitmap src = BitmapFactory.decodeResource(getResources(), id);
src= Bitmap.createScaledBitmap(src, src_width, src_height,true);
posted by Full-stack Developer 2011. 5. 25. 20:03

 px pixels 화면 픽셀 
 in inches  수학단위에서 인치
 mm millimeters 수학단위에서 밀리미터
 pt points  1point = 1/72 inch
 dip | dp density independent pixels 1dp = 160dpi(dots per inch)
따라서 1inch에 160개 점있는 display에서 1dp는 1pixel과 같음
 sp scaled independent pixels   사용자가 설정한 글꼴설정에 따라 크기 조절

posted by Full-stack Developer 2011. 5. 19. 13:58
@Override
 public boolean onCreateOptionsMenu(Menu menu)
 {
  menu.add(0, 1, 0, "Update").setIcon(R.drawable.update);
  return super.onCreateOptionsMenu(menu);
 }
 
 @Override
 public boolean onOptionsItemSelected(MenuItem item)
 {
  switch ( item.getItemId() ) {
  case 1:
   InitContents();
   Toast.makeText(ctx, "Update Success.", Toast.LENGTH_SHORT);
   return true;
  }
  return false;
 }

-----------------------------------------------------

menu.add(0, 1, 0, "Update").setIcon(R.drawable.update);
Parameters
groupId The group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order. See getOrder().
title The text to display for the item.
posted by Full-stack Developer 2011. 5. 16. 14:44
Webview content = new Webview(this);

String data="<html>"+
   "<head>"+ 
   "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"+
   "</head>"+
   "<body>"+
    "<div style=\"text-align:left\">"
    +"글로벌 금융위기 전후 4년간 한국인의20% 실질 재산이 6분의 1이나 감소한 것으 "   
+"</div>"+
   "</body>"+
   "</html>";



   content.loadData(data,"text/html;charset=UTF-8","UTF-8");

위와같이 할시 페이지를 찾을 수 없습니다가 나올 것이다...

이유는... %때문에..  이것을 html 특수문자표에서 해당 특수기호와 동일한 특수문자를 replace 시켜야한다.

String tuning = data;
   tuning = tuning.replaceAll("%", "&#37;");
   tuning = tuning.replaceAll("\n", "<br>");

위와같이 replaceAll을 이용해서 바꾸어주면 정상적으로 나올것이다...


posted by Full-stack Developer 2011. 5. 13. 17:51

보내는 부분
Intent DetailView = new Intent(현제클레스.this, 받는엑티비티클레스이름.class);
       DetailView.putExtra("URL", "데이터를 넣는자리");
       startActivity(DetailView);

★현제클레스.this 이부분에 this(extends Activity한클레스의)를 넣어줘도되고 해당 Activity의 Context를 넣어줘도되고 기호에 맞게 ㅋ

받는 부분
Intent idv = getIntent();
  
  String url = idv.getStringExtra("URL");

★url에 "데이터를 넣는자리" 가 들어가겠죠..

posted by Full-stack Developer 2011. 5. 13. 17:46


File datafile = new File("/sdcard/filename.txt");
  StringBuilder data = new StringBuilder(); 
  try {    
   BufferedReader reader = new BufferedReader(new FileReader(datafile));    
   String readdata;     
   while ((readdata = reader.readLine())!=null) {        
    data.append(readdata); 
    }
   } catch (IOException e) {    
   }
  }



String tmp="";
String url="/sdcard/filename.txt";
  
  try {
   BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(url)), "UTF-8"));
   String line;     
   while ((line = br.readLine()) != null) {        
    tmp+=line;
   }
  } catch (IOException e) { 
  }


FileInputStream fis = new FileInputStream(url);
   Reader in = new InputStreamReader(fis, "UTF-16");
   String tmp="";
   char []buf = new char[fis.available()];
   in.read(buf);
   tmp = new String(buf);
   fis.close();

posted by Full-stack Developer 2011. 5. 13. 13:46

리소스의 이미지 load

Bitmap bitMapImage = BitmapFactory.decodeResource(getResources(), R.drawable.bar_port);

sdcard의 이미지 load

Bitmap bitMapImage = BitmapFactory.decodeFile("/sdcard/img.jpg");
posted by Full-stack Developer 2011. 5. 13. 13:42

Bitmap -> Drawable

Bitmap bitmap = new Bitmap (...);

Drawable drawable = new BitmapDrawable(bitmap);


Drawable -> Bitmap

Bitmap bitmap = Bitmap.createBitmap(width, height, true);
Drawable iconDrawable =
packageManager.getActivityIcon(resolveInfo.activityInfo);
Canvas canvas = new Canvas(bitmap);

drawable.setBounds(0, 0, width, height);
drawable.draw(canvas);

posted by Full-stack Developer 2011. 5. 4. 12:51

int w = getWindow().getWindowManager().getDefaultDisplay().getWidth();
int h = getWindow().getWindowManager().getDefaultDisplay().getHeight();
posted by Full-stack Developer 2011. 4. 25. 11:04


1.화면이 가로, 세로 변경시 이벤트

@Override
    public void onConfigurationChanged(Configuration newConfig) {

      super.onConfigurationChanged(newConfig);
       int cnt=0;
         switch(newConfig.orientation){

            case Configuration.ORIENTATION_LANDSCAPE:
             //TODO
            break;

            case Configuration.ORIENTATION_PORTRAIT:  
            //TODO
            break;

         } 
    
    }

2.현제 화면이 가로, 세로인지 확인
Configuration config = getResources().getConfiguration();
if(config.orientation == Configuration.ORIENTATION_PORTRAIT){
 //TODO
}
else if(config.orientation == Configuration.ORIENTATION_LANDSCAPE){
 //TODO
}

posted by Full-stack Developer 2011. 4. 18. 13:22


@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        requestWindowFeature(Window.FEATURE_NO_TITLE);//타이틀바 제거
        setContentView(R.layout.main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//풀스크린

    }

posted by Full-stack Developer 2011. 4. 14. 11:32
WebView wv = new WebView(this);
wv.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); 
posted by Full-stack Developer 2011. 4. 14. 11:05

 

WebView wv = new WebView(this);


wv.setVerticalScrollBarEnabled(false); 
wv.setHorizontalScrollBarEnabled(false);

posted by Full-stack Developer 2011. 4. 11. 11:44

1.Help -> Install New software 클릭!

 


경로: http://www.appspresso.com/update/site.xml

2.설치 ㄱㄱ

3.window -> preferences 클릭!


자신의 JDK경로 설정!

4.그다음부터는 프로젝트 생성도 해보시고 잘다뤄보시길...

-window -> open perspective -> Appspresso 클릭!
-file -> new -> Appspresso project 클릭! (프로젝트 생성)
posted by Full-stack Developer 2011. 4. 5. 11:13
VideoView vv = (VideoView)findViewById(R.id.videoView1);
       MediaController mc =  new MediaController(this);
       vv.setVideoURI(Uri.parse("rtsp://xxxxxxxxxx/xxxxx.mp4"));
       vv.setMediaController(mc);
       vv.start();

경로가 rtsp(Real Time Streaming Protocol)경로여야 한다.
posted by Full-stack Developer 2011. 3. 31. 10:47
 
보이기
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

숨기기
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);

출처 http://eddykudo.com/45
posted by Full-stack Developer 2011. 3. 30. 10:14

// 웹페이지 띄우기    

Uri uri = Uri.parse("http://www.google.com");    

Intent it  = new Intent(Intent.ACTION_VIEW,uri);    

startActivity(it);    

  

// 구글맵 띄우기    

Uri uri = Uri.parse("geo:38.899533,-77.036476");    

Intent it = new Intent(Intent.Action_VIEW,uri);    

startActivity(it);     

  

// 구글 길찾기 띄우기    

Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=출발지주소&daddr=도착지주소&hl=ko");    

Intent it = new Intent(Intent.ACTION_VIEW,URI);    

startActivity(it);    

  

// 다이얼러 띄우기   

Uri uri = Uri.parse("tel:xxxxxx");    

Intent it = new Intent(Intent.ACTION_DIAL, uri);   

startActivity(it);   

  

// 전화걸기   

// 퍼미션을 잊지 마세요. <USES-PERMISSION id=android.permission.CALL_PHONE />    

Uri uri = Uri.parse("tel.xxxxxx");    

Intent it = new Intent(Intent.ACTION_CALL,uri);    

startActivity(it);   

  

// SMS/MMS 발송    

Intent it = new Intent(Intent.ACTION_VIEW);    

it.putExtra("sms_body""The SMS text");    

it.setType("vnd.android-dir/mms-sms");    

startActivity(it);   

  

// SMS 발송    

Uri uri = Uri.parse("smsto:0800000123");    

Intent it = new Intent(Intent.ACTION_SENDTO, uri);    

it.putExtra("sms_body""The SMS text");    

startActivity(it);   

  

// MMS 발송    

Uri uri = Uri.parse("content://media/external/images/media/23");    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra("sms_body""some text");    

it.putExtra(Intent.EXTRA_STREAM, uri);    

it.setType("image/png");    

startActivity(it);     

  

// 이메일 발송    

Uri uri = Uri.parse("mailto:xxx@abc.com");    

Intent it = new Intent(Intent.ACTION_SENDTO, uri);    

startActivity(it);    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");    

it.putExtra(Intent.EXTRA_TEXT, "The email body text");    

it.setType("text/plain");    

startActivity(Intent.createChooser(it, "Choose Email Client"));   

Intent it = new Intent(Intent.ACTION_SEND);   

String[] tos = {"me@abc.com"};   

String[] ccs = {"you@abc.com"};   

it.putExtra(Intent.EXTRA_EMAIL, tos);   

it.putExtra(Intent.EXTRA_CC, ccs);   

it.putExtra(Intent.EXTRA_TEXT, "The email body text");   

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   

it.setType("message/rfc822");   

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// extra 추가하기    

Intent it = new Intent(Intent.ACTION_SEND);    

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");    

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");    

sendIntent.setType("audio/mp3");    

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// 미디어파일 플레이 하기    

Intent it = new Intent(Intent.ACTION_VIEW);    

Uri uri = Uri.parse("file:///sdcard/song.mp3");    

it.setDataAndType(uri, "audio/mp3");    

startActivity(it);    

Uri uri = Uri.withAppendedPath(    

  MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");    

Intent it = new Intent(Intent.ACTION_VIEW, uri);    

startActivity(it);   

  

// 설치 어플 제거    

Uri uri = Uri.fromParts("package", strPackageName, null);    

Intent it = new Intent(Intent.ACTION_DELETE, uri);    

startActivity(it);    

  

// APK파일을 통해 제거하기    

Uri uninstallUri = Uri.fromParts("package""xxx"null);    

returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);    

  

// APK파일 설치    

Uri installUri = Uri.fromParts("package""xxx"null);    

returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);    

  

// 음악 파일 재생    

Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");    

returnIt = new Intent(Intent.ACTION_VIEW, playUri);    

  

// 첨부파일을 추가하여 메일 보내기    

Intent it = new Intent(Intent.ACTION_SEND);   

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   

it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");   

sendIntent.setType("audio/mp3");   

startActivity(Intent.createChooser(it, "Choose Email Client"));    

  

// 마켓에서 어플리케이션 검색 (패키지명은 어플의 전체 패키지명을 입력해야 합니다.)   

Uri uri = Uri.parse("market://search?q=pname:pkg_name");   

Intent it = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(it);   

  

// 마켓 어플리케이션 상세 화면 (아이디의 경우 마켓 퍼블리싱사이트의 어플을 선택후에 URL을 확인해보면 알 수 있습니다.)  

Uri uri = Uri.parse("market://details?id=어플리케이션아이디");   

Intent it = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(it);   

  

// 구글 검색    

Intent intent = new Intent();    

intent.setAction(Intent.ACTION_WEB_SEARCH);    

intent.putExtra(SearchManager.QUERY,"searchString")    

startActivity(intent);  

출처: http://hoya4232.tistory.com/716
[출처] http://snipt.net/Martin/tag/android

posted by Full-stack Developer 2011. 2. 28. 14:13

 Display dp = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
 int width = dp.getWidth();   
 int height = dp.getHeight();
posted by Full-stack Developer 2011. 2. 16. 09:12


빨간색 박스안에 알맞게 변경해주면된다.
fill_parent를 사용하든.. wrap_content를 사용하든.. 수치를 직접넣든... 등등
posted by Full-stack Developer 2011. 2. 11. 15:01


webview.getSettings().setUseWideViewPort(true);

ture면 자동개행 안하는것이고

false면 자동개행 한다는 것임.

default는 false로 되있음.
posted by Full-stack Developer 2011. 2. 11. 14:54

webview.getSettings().setUseWideViewPort(true);//must be true
webview.setInitialScale(1);

If getUseWideViewPort() is true
 0 is default 25 is 25% 50 is 50%  default is 100%
posted by Full-stack Developer 2011. 2. 11. 09:15

기존에 TextView의 paint를 가져와 breakword를 사용하여 개행을 시도해보았지만

단어단위로 개행은 했지만 양끝정렬처럼 깔끔하게 실행되지 않은 문제가 있었습니다.

그리하여 WebView를 이용하여 Text를 뿌려준결과 양끝정렬을 하여 텍스트가 깔끔하게

개행되었습니다.



posted by Full-stack Developer 2011. 1. 20. 08:56


TextView 단어 단위로 개행 하는 코드입니다.
기본적으로 개행할때 공백(스페이스바)단위로 개행해서
라인이 들쑥날쑥해서 보기 않좋더라구요...
그래서 구현한건데... 뭐 그목적은아니지만..
아... 나름 힘들었음 ^^
아! 저기 float frameWidth는 택스트뷰의 width를 가져오시면 됩니다.
뭐 쭉보시면 이해하실꺼에요 ^^
posted by Full-stack Developer 2011. 1. 6. 18:01



new StringTokenizer(문자열,토큰할문자열);
ex)
      문자열 : 1|12|123|      
      토큰할문자열: |
      결과: 1
              12
              123