Checkbox 이미지 활용하기

안드로이드/android 2013. 5. 8. 15:02

체크박스를 예쁘게 또는 기능 적으로 이미지의 힘을 빌려야 할떄가 있다

특히 3.0 이하에서는 더욱더 그렇다


얼릉 4.0 이하는 사라져야 하는데...


// layout

<CheckBox android:id="@+id/cchkbox" android:layout_width="wrap_content" android:layout_height="wrap_content"

        android:layout_alignParentLeft="true" android:layout_marginLeft="3dp"

        android:padding="10dp"

        android:focusable="false" android:clickable="false" android:button="@drawable/checkbox_sel" />



// drawable/checkbox_sel.xml


<?xml version="1.0" encoding="utf-8"?>

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

    <item android:state_checked="false" android:drawable="@drawable/checkbox_dis" />

    <item android:state_checked="true" android:drawable="@drawable/checkbox_ena" />

    <item android:drawable="@drawable/checkbox_dis" />

</selector>



// JAVA

CheckBox ivChk = (CheckBox) findViewById(R.id.cchkbox);


ivChk.setChecked(true);     // @drawable/checkbox_ena 이 녀석이 활성화 될거임(체크된 상태)

ivChk.setChecked(false);   // @drawable/checkbox_dis 이 녀석이 활성화 될거임(체크되지 않은 상태)



android:launchMode singleTop과 singleTask 의 차이점

안드로이드/android 2013. 5. 8. 13:18

메니페스트에

<activity android:name=".Test" android:launchMode="singleTop" android:label="@string/app_name"  />


1. startActivityForResult 에 대해 반응을 보인다.

          startActivityForResult(i, Global.LAUNCHED_ACTIVITY_VIEW);

            protected void onActivityResult(int requestCode, int resultCode, Intent data){}


2. 나를 여러번 호출하더라도 나를 최상단에 놓기 때문에 같은 페이지로 이전 화면이 쌓이질 안는다



<activity android:name=".Test" android:launchMode="singleTask" android:label="@string/app_name"  />

1. startActivityForResult 에 대해 실행이 불가능하다 왜냐 자신 왜에 어느것도 이전에 존재할 수 없기 때문이다

2. 나를 여러번 호출하더라도 나를 최상단에 놓기 때문에 같은 페이지로 이전 화면이 쌓이질 안는다

위젯 사이즈

안드로이드/android 2013. 4. 16. 10:40

// rex/xml/


<?xml version="1.0" encoding="utf-8"?>

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="60dp"
    android:minHeight="60dp"
    android:label="@string/name"
    android:updatePeriodMillis="86400000"
    android:initialLayout="@layout/widget_1x1.xml"
    >
</appwidget-provider>




android:minWidth="60dp"
android:minHeight="60dp"


1x1 : 60dp x 60dp

1x3 : 60dp x 180dp

2x1 : 120dp x 60dp

2x2 : 200dp x 200dp

3x1 : 180dp x 60dp

4x1 : 240dp x 60dp



webview 클립보드 (Copy & paste) 에 내용 넣기

안드로이드/android 2013. 4. 5. 13:26

webview.setOnLongClickListener(gestureListener);



View.OnLongClickListener gestureListener = new View.OnLongClickListener() {

@Override

public boolean onLongClick(View v) {

_ALERT_CODE_=700;

Log.i(TAG,v.getClass().getSimpleName()+"");

if(v instanceof WebView){

alert.showConfirm(

"", // title

getResources().getString(R.string.copy_contents),// message 

getResources().getString(R.string.alert_ok), // button1 타이틀

getResources().getString(R.string.alert_cancel) // button2 타이틀

);

}

return false;

}

    };

    

    private Runnable onClipBoard=new Runnable() {

        public void run() {             

//           if (!clipboardManager.getText().toString().equalsIgnoreCase(description)) {

//                 Toast.makeText(getApplicationContext(),

//                         "selected Text = " + clipboardManager.getText().toString(),

//                         Toast.LENGTH_LONG).show();

//                 clipboardManager.setText(description);

//           } else {

        try{

        webview.postDelayed(onClipBoard, 1000);

}catch(ActivityNotFoundException e){ e.printStackTrace(); }

catch(Exception e){ e.printStackTrace(); }

           

//           }

        }

     };

Button drawableLeft 자바에서 설정하기

안드로이드/android 2013. 3. 27. 16:11

Drawable img = getContext().getResources().getDrawable( R.drawable.smiley );
img.setBounds( 0, 0, 60, 60 );
txtVw.setCompoundDrawables( img, null, null, null );

or

Drawable img = getContext().getResources().getDrawable( R.drawable.smiley );
txtVw.setCompoundDrawablesWithIntrinsicBounds( img, null, null, null );
// 아이콘 정렬

setCompoundDrawablesWithIntrinsicBounds( 왼쪽, , 오른쪽, 아래 );