'sample'에 해당되는 글 38건

  1. 2011.11.07 Android - Disable orientation change / 가로, 세로 변경시 초기화 해제
  2. 2011.11.04 Android - Video loading dialog in VideoView / VideoView 로딩되기 전 로딩 다이얼로그 생성
  3. 2011.10.17 Android - Methods GET and POST in HTML forms//http전송 get방식, post방식
  4. 2011.10.12 Android - custom button pressed image change
  5. 2011.10.11 Android - Custom Toast
  6. 2011.10.05 Android - Custom Swipe-Fling Scroll View / like home screen view
  7. 2011.10.05 Android - Custom Dialog Set Root Background
  8. 2011.10.05 Android - Custom CheckBox
  9. 2011.10.05 Android - Custom RadioButton
  10. 2011.10.05 Android - Custom Dialog onClick Event
  11. 2011.10.05 Android - custom indeterminate progressbar
  12. 2011.07.28 Android - Activity for result /자신을 호출한 엑티비티에게 데이터 보내기
  13. 2011.06.15 Android - to use json[JSONArray,JSONObject](example) /안드로이드에서 json 사용하기
  14. 2011.06.14 Android - read & write ini(properties) in android SDcard/ 안드로이드에서 ini(properties) 사용하기
  15. 2011.06.13 Android - cmd로 수동 apk 생성(예제)/To build apk from the command line(Example)/자동배포
  16. 2011.06.02 Android - load resource animation/ 리소스에 있는 애니메이션 가져오기
  17. 2011.06.02 Android - portrait or landscape hold /화면 고정 시키기 / 회전 잠금
  18. 2011.06.01 Android - GestureDetector, fling event in code/scroll/좌우스크롤/좌우넘기기
  19. 2011.05.31 Android - generate jar file/jar파일 만들기/lib 만들기
  20. 2011.05.27 Android - Listview divider / Listview gap space
  21. 2011.05.27 Android - view set margin in code
  22. 2011.05.27 Android - Bitmap resize
  23. 2011.05.19 Android - Create Option
  24. 2011.05.16 Android - Webview에서 loadData할시 페이지를 찾을수 없습니다 나올때..
  25. 2011.05.13 Android - Activity간 데이터 주고 받기
  26. 2011.05.13 Android - Bitmap, Drawable convert
  27. 2011.05.12 WPF - 단축키(Shortcut-SC) 만들기
  28. 2011.05.12 WPF - Groupbox Header Color 변경
  29. 2011.05.12 WPF - OpenFileDialog Sample
  30. 2011.04.25 Android - 화면 가로, 세로 이벤트 및 현제 화면상태 확인
posted by Solver Full-stack Developer 2011.11.07 18:22
<activity android:name="MainActivity" android:configChanges="keyboardHidden|orientation">

 

안녕하세요 ^^

잠깐 설명을 해볼까 해요.

폰에서 화면전환시 Activity가 계속 초기화되는 문제를 해결하기위해서 AndroidManifest.xml에서

해당 Activity에 위에 노랑색부분처럼 설정을 해줘야 가로, 세로 전환할때 초기화가 안됩니다.

위에 노랜색부분처럼 설정을 안해주신다면 ->(가로세로 전환한 시점) 

 onCreate -> onCreate -> onCreate ... 이겠죠?

설정을 해주시면

onCreate-> onConfigurationChanged -> onConfigurationChanged ->...


와같은 식으로 동작합니다.

도움되셨으면 좋겟네요 ㅎ

Enjoy coding, Don't be angry :)
 

신고
posted by Solver Full-stack Developer 2011.11.04 14:16
Step 1. SetOnPreparedListener

public class SampleVideo extends Activity {
VideoLoding dlg;
VideoView vv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videopage);
Intent i = getIntent();
if(dlg==null){
dlg = new VideoLoding(this,true);
dlg.show();
}
vv = (VideoView)findViewById(R.id.video);
        MediaController mc =  new MediaController(this);
        vv.setVideoURI(Uri.parse(i.getStringExtra("url")));
        vv.setMediaController(mc);
        vv.setOnPreparedListener(new OnPreparedListener() {

            public void onPrepared(MediaPlayer arg0) {
                if(dlg!=null && dlg.isShowing()){
        dlg.dismiss();
        dlg=null;
        }
            }
        });
        vv.start();
}

}

Do u wanna custom indeterminate progressbar?

here is http://codedb.tistory.com/entry/Android-custom-indeterminate-progressbar


안녕하세요 ^^

설명을 잠시 해보겠습니다.

VideoView를 start하기전에 로딩 다이얼로그를 show()해주세요.
그리고 setOnPreparedListener을 설정해주시고 로딩 다이얼로그를 dismiss()해주세요.

즉 play준비가 다되었을때 다이얼로그를 종료한다는 이야기죠.

혹시 커스텀 로딩 다일로그가 필요하세요? 아래링크로 가세요!

http://codedb.tistory.com/entry/Android-custom-indeterminate-progressbar

도움이 되었으면 좋겠네요 ㅎ

즐코딩! 낫빡침! 


신고
posted by Solver Full-stack Developer 2011.10.17 16:32
1.Get 방식
example)

{
...
String result = sendData("http://xxx.xxx.xxx/xxx.asp?title=leeminjung&type=article");
...
}

private static String sendData(String addr){
StringBuilder html = new StringBuilder();
try{
URL url = new URL(addr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
if(conn != null){
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
for(;;){
String line = br.readLine();
if(line == null)break;
html.append(line );
html.append('\n');
}
br.close();
}
conn.disconnect();
}
}
catch(Exception ex){;}
return html.toString();


2.Post 방식

example)

{
...
   login();
... 


public void login() {
        try {
             URL url = new URL("http://xxx.xxx.xx.xx/xxxx/xxxx/xxx");      
             HttpURLConnection http = (HttpURLConnection) url.openConnection();  

             http.setDefaultUseCaches(false);                                           
             http.setDoInput(true);
             http.setDoOutput(true);
             http.setRequestMethod("POST");
             http.setRequestProperty("content-type", "application/x-www-form-urlencoded");
             
             EditText pwet = (EditText)findViewById(R.id.login_pw_edit);
             EditText idet = (EditText)findViewById(R.id.login_id_edit);

             StringBuffer buffer = new StringBuffer();
                     
buffer.append("LOGIN__USER_ID").append("=").append(idet.getText().toString()).append("&");            
             buffer.append("LOGIN__USER_PW").append("=").append(pwet.getText().toString()); 
                       
             OutputStreamWriter outStream = new OutputStreamWriter(http.getOutputStream(), "EUC-KR");
             PrintWriter writer = new PrintWriter(outStream); 
             writer.write(buffer.toString());//send data
             writer.flush();

             InputStreamReader tmp = new InputStreamReader(http.getInputStream(), "EUC-KR"); 
             BufferedReader reader = new BufferedReader(tmp);
             StringBuilder builder = new StringBuilder();
             String str;
             while ((str = reader.readLine()) != null) {
                  builder.append(str + "\n");
             }
             String  result = builder.toString();//request result
            ...
        } catch (MalformedURLException e) {;} catch (IOException e) {;} 


안녕하세요 ^^
설명을 조금 해드리겠습니다 ㅎ
우선 get방식은 경로에 위에 예제에도 나왔듯이 url에  ?변수명=데이터식으로 이어붙이기를 계속
하시면 되겠죠? 예제보시면 딱 아~ 하실꺼에요..(제 희망사항 ㅠ_ㅠ)

그리고 post방식은  2.post방식 예제에서 노란색으로 표시된 부분을 보시면 변수명 데이터 삽입한
게 보이실 거에요 ㅎ
그럼 응용하면 되겠죠?

도움 되셧길 바래요~

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.12 18:21
Step 1. Create CustomButton.xml
res/drawable/custombtn.xml <- create custombtn.xml

 <?xml version="1.0" encoding="utf-8"?> 
<selector  xmlns:android="http://schemas.android.com/apk/res/android">
<item 
    android:state_pressed="false"
    android:drawable="@drawable/bu4_searchall"/>
<item 
    android:drawable="@drawable/bu4_searchall_o"/>
</selector> 

Step 2. To Use 
-ex)res/layout/main.xml 
...
<ImageView
android:src="@drawable/custombtn"
android:id="@+id/main_pressedimgtest_iv" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
/> 
... 

Step 3. SetOnClickListener
-user source  ex)src/com.xxx.xxx/main.java
...
 ImageView custombtn = (ImageView)findViewById(R.id.main_pressedimgtest_iv);
 custombtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
... 

안녕하세요 ^^
설명을 해드릴까 합니다.

이건 하단 컨트롤바같은 UI를 만들때 사용자가 press할때 이미지를 변경해주는 방법이에요.
사용자에게 터치감을 주기위해서 사용했습니다.

방법은 우선 버튼의 Step1처럼 버튼 누를시 이미지 변경되게 구현하구요
Step2에서 구현한 커스텀UI를 적용해요  Step2에 노란색 부분을 보시면 알수있겠죠?
Step3에서 클릭이벤트를 설정해줘야 press를 하겠죠?

도움되셧길 바랍니다. ㅎ

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.11 14:14
TextView customview = new TextView(ctx);
customview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,                                                                   LayoutParams.WRAP_CONTENT));
Bitmap src = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.and_pop);
src= Bitmap.createScaledBitmap(src, 600, 50,true);
customview.setBackgroundDrawable( new BitmapDrawable(src));

customview.setText(msg.getData().getCharSequence("data"));
customview.setGravity(Gravity.CENTER_VERTICAL);
customview.setPadding(100, 10, 0, 0);

Toast custo = new Toast(ctx);
custo.setView(customview);//insert u r custom view
custo.setGravity(Gravity.CENTER_VERTICAL, 10, 10);
custo.setDuration(Toast.LENGTH_LONG);
custo.show();


안녕하세요 ^^
잠시 설명을 해볼까 합니다.

Toast를 커스텀하는것인데요.
동적으로 원하시는 UI로 구현하시고 혹은 xml로 UI구현하신걸 사용하셔도 무방하구요.
중요한부분은 그렇게 생성한 View를 Toast에 setView를 해주시면 끗!


노란색부분처럼 하시면 되요!

도움되셧길 바랍니다.

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.05 17:44
Step 1.create  CustomViewer.java  and custom!

import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.Scroller;


public class CustomViewer extends ViewGroup {
private Scroller mScroller;
private VelocityTracker mVelocityTracker;
 private int mScrollX = 0;
private int mCurrentScreen = 0;//현제 창의 위치
 private float mLastMotionX;
 private static final String LOG_TAG = "FlingAndScrollViewer";
 private static final int SNAP_VELOCITY = 1000;//속도
 private final static int TOUCH_STATE_REST = 0;
private final static int TOUCH_STATE_SCROLLING = 1;
 private int mTouchState = TOUCH_STATE_REST;
 private int mTouchSlop = 0;
 public CustomViewer(Context context) {
    super(context);
    mScroller = new Scroller(context);
     mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
     this.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));
}
 public CustomViewer(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = getContext().obtainStyledAttributes(attrs,
            R.styleable.FlingAndScrollViewer);
    mCurrentScreen = a.getInteger(
            R.styleable.FlingAndScrollViewer_default_screen, 0);
     mScroller = new Scroller(context);
     mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
     this.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));
 }
 public void setInitialPosition(int initialPosition){
    mCurrentScreen = initialPosition;
}
 @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    /*
     * This method JUST determines whether we want to intercept the motion.
     * If we return true, onTouchEvent will be called and we do the actual
     * scrolling there.
     */
     /*
     * Shortcut the most recurring case: the user is in the dragging state
     * and he is moving his finger. We want to intercept this motion.
     */
    final int action = ev.getAction();
    if ((action == MotionEvent.ACTION_MOVE)
            && (mTouchState != TOUCH_STATE_REST)) {
        return true;
    }
     final float x = ev.getX();
     switch (action) {
    case MotionEvent.ACTION_MOVE:
        /*
         * mIsBeingDragged == false, otherwise the shortcut would have
         * caught it. Check whether the user has moved far enough from his
         * original down touch.
         */
         /*
         * Locally do absolute value. mLastMotionX is set to the y value of
         * the down event.
         */
        final int xDiff = (int) Math.abs(x - mLastMotionX);
         boolean xMoved = xDiff > mTouchSlop;
         if (xMoved) {
            // Scroll if the user moved far enough along the X axis
            mTouchState = TOUCH_STATE_SCROLLING;
        }
        break;
     case MotionEvent.ACTION_DOWN:
        // Remember location of down touch
        mLastMotionX = x;
         /*
         * If being flinged and user touches the screen, initiate drag;
         * otherwise don't. mScroller.isFinished should be false when being
         * flinged.
         */
        mTouchState = mScroller.isFinished() ? TOUCH_STATE_REST
                : TOUCH_STATE_SCROLLING;
        break;
     case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        // Release the drag
        mTouchState = TOUCH_STATE_REST;
        break;
    }
     /*
     * The only time we want to intercept motion events is if we are in the
     * drag mode.
     */
    return mTouchState != TOUCH_STATE_REST;
}
 @Override
public boolean onTouchEvent(MotionEvent event) {
     if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(event);
     final int action = event.getAction();
    final float x = event.getX();
     switch (action) {
    case MotionEvent.ACTION_DOWN:
        Log.i(LOG_TAG, "event : down");
        /*
         * If being flinged and user touches, stop the fling. isFinished
         * will be false if being flinged.
         */
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
         // Remember where the motion event started
        mLastMotionX = x;
        break;
    case MotionEvent.ACTION_MOVE:
        // Log.i(LOG_TAG,"event : move");
        // if (mTouchState == TOUCH_STATE_SCROLLING) {
        // Scroll to follow the motion event
        final int deltaX = (int) (mLastMotionX - x);
        mLastMotionX = x;
         // Log.i(LOG_TAG, "event : move, deltaX " + deltaX + ", mScrollX " +
        // mScrollX);
         if (deltaX < 0) {
            if (mScrollX > 0) {
                scrollBy(Math.max(-mScrollX, deltaX), 0);
            }
        } else if (deltaX > 0) {
            final int availableToScroll = getChildAt(getChildCount() - 1)
                    .getRight() - mScrollX - getWidth();
            if (availableToScroll > 0) {
                scrollBy(Math.min(availableToScroll, deltaX), 0);
            }
        }
        // }
        break;
    case MotionEvent.ACTION_UP:
        Log.i(LOG_TAG, "event : up");
        // if (mTouchState == TOUCH_STATE_SCROLLING) {
        final VelocityTracker velocityTracker = mVelocityTracker;
        velocityTracker.computeCurrentVelocity(1000);
        int velocityX = (int) velocityTracker.getXVelocity();
         if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
            // Fling hard enough to move left
            snapToScreen(mCurrentScreen - 1);
        } else if (velocityX < -SNAP_VELOCITY
                && mCurrentScreen < getChildCount() - 1) {
            // Fling hard enough to move right
            snapToScreen(mCurrentScreen + 1);
        } else {
            snapToDestination();
        }
         if (mVelocityTracker != null) {
            mVelocityTracker.recycle();
            mVelocityTracker = null;
        }
        // }
        mTouchState = TOUCH_STATE_REST;
        break;
    case MotionEvent.ACTION_CANCEL:
        Log.i(LOG_TAG, "event : cancel");
        mTouchState = TOUCH_STATE_REST;
    }
    mScrollX = this.getScrollX();
     return true;
}
 private void snapToDestination() {
    final int screenWidth = getWidth();
    final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
    Log.i(LOG_TAG, "from des");
    snapToScreen(whichScreen);
}
 public void snapToScreen(int whichScreen) {
    Log.i(LOG_TAG, "snap To Screen " + whichScreen);
    mCurrentScreen = whichScreen;
    final int newX = whichScreen * getWidth();
    final int delta = newX - mScrollX;
    mScroller.startScroll(mScrollX, 0, delta, 0, Math.abs(delta) * 2);
    invalidate();
}
 public void setToScreen(int whichScreen) {
    Log.i(LOG_TAG, "set To Screen " + whichScreen);
    mCurrentScreen = whichScreen;
    final int newX = whichScreen * getWidth();
    mScroller.startScroll(newX, 0, 0, 0, 10);
    invalidate();
}
 @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int childLeft = 0;
     final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != View.GONE) {
            final int childWidth = child.getMeasuredWidth();
            child.layout(childLeft, 0, childLeft + childWidth,
                    child.getMeasuredHeight());
            childLeft += childWidth;
        }
    }
 }
 @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     final int width = MeasureSpec.getSize(widthMeasureSpec);
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    if (widthMode != MeasureSpec.EXACTLY) {
        throw new IllegalStateException("error mode.");
    }
     final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    if (heightMode != MeasureSpec.EXACTLY) {
        throw new IllegalStateException("error mode.");
    }
     // The children are given the same width and height as the workspace
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
    }
    Log.i(LOG_TAG, "moving to screen " + mCurrentScreen);
    scrollTo(mCurrentScreen * width, 0);
}
 @Override
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        mScrollX = mScroller.getCurrX();
        scrollTo(mScrollX, 0);
        postInvalidate();
    }
}
 /**
 * Return the parceable instance to be saved
 */
@Override
protected Parcelable onSaveInstanceState() {
    final SavedState state = new SavedState(super.onSaveInstanceState());
    state.currentScreen = mCurrentScreen;
    return state;
}
 /**
 * Restore the previous saved current screen
 */
@Override
protected void onRestoreInstanceState(Parcelable state) {
    SavedState savedState = (SavedState) state;
    super.onRestoreInstanceState(savedState.getSuperState());
    if (savedState.currentScreen != -1) {
        mCurrentScreen = savedState.currentScreen;
    }
}
 // ========================= INNER CLASSES ==============================
 public interface onViewChangedEvent {
    void onViewChange(int currentViewIndex);
}
 /**
 * A SavedState which save and load the current screen
 */
public static class SavedState extends BaseSavedState {
    int currentScreen = -1;
     /**
     * Internal constructor
     *
     * @param superState
     */
    SavedState(Parcelable superState) {
        super(superState);
    }
     /**
     * Private constructor
     *
     * @param in
     */
    private SavedState(Parcel in) {
        super(in);
        currentScreen = in.readInt();
    }
     /**
     * Save the current screen
     */
    @Override
    public void writeToParcel(Parcel out, int flags) {
        super.writeToParcel(out, flags);
        out.writeInt(currentScreen);
    }
     /**
     * Return a Parcelable creator
     */
    public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
        public SavedState createFromParcel(Parcel in) {
            return new SavedState(in);
        }
         public SavedState[] newArray(int size) {
            return new SavedState[size];
        }
    };
}

--------------------------------------------------------------------------------
Step 2. Add attrs
add res/values/attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="CustomViewer">
        <attr name="default_screen" format="integer"/>
    </declare-styleable>
</resources> 
--------------------------------------------------------------------------------
Step 3. Use u r layout!
ex)res/layout/main.xml 
<com.xxxx.xxxx.CustomViewer
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:id="@+id/flingScrollViewer"/> 

안녕하세요 ^^
설명을 조금 해보겠습니다.

이 커스텀 UI를 사용하면 폰에서 홈스크린처럼 다음페이지,현제페이지, 전페이지를 스크롤 이동하면 모두보이는 기능입니다. 말이좀 이상한가요?
홈스크린이나 포토 갤러리와 같은 layout이라는 것입니다.

fling할때 가속도와 horizental scroll을 적절히 사용되었습니다.

도움되셧길 바랍니다.

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.05 17:18
public class CustomDialog extends Dialog implements android.view.View.OnClickListener{
CustomDialog dlg;
public CustomDialog(Context context) {
super(context);
getWindow().setBackgroundDrawableResource(R.drawable.img_background);
setContentView(R.layout.customdialog);
dlg=this;
Button closeBtn =(Button)findViewById(R.id.customedlg_close_btn);
closeBtn.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.customedlg_close_btn:
dlg.dismiss();
break;
}
}

}

안녕하세요 ^^
설명을 해볼까해요 ㅎ
커스텀으로 Dialog를 구현했을 시
배경화면을 변경하고 싶으시겠죠?
그때 위의 노란색 부분과같이 이미지변경을 하시거나
색을 변경하시거나 혹은 투명하게(Colors.TRANSPARENT) 만드실 수 있어요!

도움되셨길 바랍니다.

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.05 17:15
1.
<CheckBox
android:id="@+id/setting_idsave_cb"
android:button="@drawable/checkbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="아이디저장"
android:textColor="#9b9d9d"
android:textSize="16px"
android:paddingRight="35px"/>

2.
dir is.. res/drawable/checkbtn.xml

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item 
        android:state_checked="true"
        android:drawable="@drawable/img_checked" />
    <item
        android:drawable="@drawable/img_check" />
</selecto 
 

안녕하세요 ^^
설명을 해보겠습니다!

사용방법은 1번과같이 button을 커스텀한 checkbox로 세팅해주시면됩니다.
2과같이 체그될때 이미지, 체크안될을때 이미지를 설정해주시면 끗!

도움되셧길 바랍니다 ㅎ

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.05 16:52
1.
<RadioButton
android:id="@+id/setting_p_rb"
android:button="@drawable/radiobtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="개인회원 "
android:textColor="#9b9d9d"
android:textSize="16px"
android:layout_marginBottom="5px"
android:layout_marginTop="2px"
android:paddingRight="47px"/> 

2.
dir is .. res/drawable/radiobtn.xml

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item 
        android:state_checked="true"
        android:drawable="@drawable/i_radio_ch" />
    <item
        android:drawable="@drawable/i_radio" />
</selector> 

ch -> checked 

안녕하세요 ^^
설명을 잠시 해보겠어요.
CheckBox와 같은 방식으로 2번처럼 커스텀한 UI 1번처럼 button에 UI를 세팅해주시면 됩니다.

도움되셧길 바랍니다 ㅎ

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.10.05 16:47
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;

public class CustomDialog extends Dialog implements android.view.View.OnClickListener{
CustomDialog dlg;
public CustomDialog(Context context) {
super(context);
setContentView(R.layout.customdialog);
dlg=this;
Button closeBtn =(Button)findViewById(R.id.customedlg_close_btn);
closeBtn.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.customedlg_close_btn:
dlg.dismiss();
break;
}
}

}

안녕하세요 ^^
설명을 해보겠습니다.

커스텀다이얼로그를 구현할 시 클릭이벤트 생성하기가 잘안되실텐데요.
위와같이 implements를 해주시면 onclick이벤트가 생깁니다.
예제의 노란색부분을 보시면 onclick리스너를 implements 해서
onclick이벤트를 생성하여 원하는 view에 setOnClickListener를 설정해주시면
됩니다.

도움되셨길 바랍니다.ㅎ

즐코딩! 낫빡침! 


신고
posted by Solver Full-stack Developer 2011.10.05 16:33
1.
<ProgressBar
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:paddingTop="20px"
  android:indeterminateDrawable="@drawable/loadingspin"
  android:animationResolution="1"
  />

 2.
dir is .. res/drawable/loadingspin.xml

<?xml version="1.0" encoding="utf-8"?>
 <layer-list  xmlns:android="http://schemas.android.com/apk/res/android">
 <item>
  <rotate 
  android:drawable="@drawable/loading" ------------------------------↘


  android:pivotX="50%"
  android:pivotY="50%"
  android:fromDegrees="0"
  android:toDegrees="1080"
/>
  </item>
  </layer-list>

 

안녕하세요 ^^
잠시 설명을 해보겟습니다.

2번처럼 UI를 xml를 구현해주세요. drawable에 원하시는 png로 되있는 로딩 이미지를
세팅해주시고
1번처럼 indeterminateDrawable에 구현한 UI를 세팅해주시면 됩니다.

도움되셨으면 좋겠네요 ㅎ

즐코딩! 낫빡침! 


신고
posted by Solver Full-stack Developer 2011.07.28 17:23


1.Parent Activity


Intent intent = new Intent(nowclassname.this, childclassname.class);
startActivityForResult(intent,1); 

....

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(requestCode== 1 || resultCode==RESULT_OK){
if(data.getStringExtra("isEnd").equals("Y")){//use data
//TODO 
}
}
}


 


2.Child Activity 

public void onBackPressed() { // if child acticity end
super.onBackPressed();
Intent _intent = getIntent();
   _intent.putExtra("isEnd", "N");
   setResult(RESULT_OK,_intent);
   finish();


안녕하세요 ^^
설명을 좀 해드릴까 합니다. ㅎ

1번은 다른 Activity를 호출할 Activity입니다.
다른 Activity를 호출할때  startActivityForResult(Intent in,int requestCode)를 이용합니다. 예제에서 보듯이 requestCode로 구분할 수가 있습니다.빨간색으로 표시 했듯이 말이죠.

2번에서 보듯이 activity가 종료되는 시점에 데이터를 넣어주면 자신을 호출한 Activity에
setResult를 이용하여 데이터를 넘겨줄 수 잇습니다.

 도움이 되셨으면 좋겠네요 ㅎ

즐코딩! 낫빡침! 

 
신고
posted by Solver Full-stack Developer 2011.06.15 17:36
1. JSONArray

{
"number":[
    1,
    2,
    3,
    4,
    5
  ] 
}


String json4arr="{\"number\":[1,2,3,4,5]}";
        try {
        int sum=0;
        JSONObject jobj = new JSONObject(json4arr);
JSONArray jarr = jobj.getJSONArray("number");
for(int i=0;i<jarr.length();i++){
int tmp=jarr.getInt(i);
if(tmp%2==1){
sum += tmp;
}
}

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


2.JSONObject

{
    "color":{
    "top":"red",
    "bottom":"black",
    "
left":"blue",
    "right":"green"
  }
 
}

String json4obj="{\"color\":{\"top\":\"red\",\"bottom\":\"black\",\"left\":\"blue\",\"right\":\"green\"}}";
        try {
        JSONObject jobj = new JSONObject(json4obj);
        JSONObject color = jobj.getJSONObject("color");
       
       
        String top_color="";
         if(color.has("left")){
        top_color=color.getString("left");
         }
} catch (JSONException e) {
e.printStackTrace();
}

 3.aptana
 트리형식으로 json데이터를 보는데 도와준다./view JSONdata to tree type

 
http://codedb.tistory.com/entry/Android-plugging-Aptana-in-eclipe-%EC%9D%B4%ED%81%B4%EB%A6%BD%EC%8A%A4%EC%97%90%EC%84%9C-aptana-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0   <- install aptana in eclipse

안녕하세요 ^^

잠시 설명을 해볼까 해요.

1번째는 json array인데요 [] 이런형식으로 데이터가 배열(array)형식으로 되어있는 데이터를 가져옵니다. 예제 json array 샘플에서 number데이터가 그러한 예이죠.

노란색으로 표현하였듯이 getJSONArray로 number데이터를 가져와 데이터타입에 맞게 index를 넣어 get해오는데요. 예제는 숫자데이터라 getInt를 사용하였는데 그부분은 잘 구미에맞게 자유자재로 사용하실꺼라고 생각해요 ㅎ

2번째는 json object인데요. getJSONObject로 데이터를 get해오죠? 그리고 has라는 부분에 노란색으로 표시하였는데요. has는 말그대로 해당데이터가 있는지 없는지 true/false로 알아내는 함수입니다. 데이터를 가져오려하는데 없다면 곤란하겠죠? 예외처리로 혹은 다른 용도로 has로 해당데이터가 존재하는지 유무를 따질때 유명하겠네요 ㅎ 

그럼 도움되셨으면 좋겠네요 ㅎ

enjoy coding! Don't be angry! 
 

 
신고
posted by Solver Full-stack Developer 2011.06.14 11:50

1. read

 Properties ini = new Properties();
 String mode="";
 ini.load(new FileInputStream("/sdcard/init.ini")); 
 mode=ini.getProperty("version"); 


2.write

Properties ini = new Properties();
ini.put("version", "default"); // property Add
ini.setProperty("version", "single"); 
ini.store(new FileOutputStream("/sdcard/FTPTemp/init.ini",true), "Initialize"); //save
신고
posted by Solver Full-stack Developer 2011.06.13 17:55
참고 사진 출처: http://asantoso.wordpress.com



Step 1. Generate R.java

cd c:\\android\androidsdk\platform-tools
aapt package -m -J "C:\Android\Workspace\ProjectName\gen" -M "C:\Android\Workspace\ProjectName\AndroidManifest.xml" -S "C:\Android\Workspace\ProjectName\res" -j "C:\Android\Workspace\ProjectName\libs" -I "C:\Android\AndroidSDK\platforms\android-7\android.jar"

Step 2. Compile src&R.java
 
cd C:\Program Files\Java\jdk1.6.0_23\bin
 
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\gen\com\Company\PackageName1\R.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageName2\C1.java" -cp "C:\Android\Workspace\ProjectName\libs\JarName.jar"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageName2\C2.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageName2\C3.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C4.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C5.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C6.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C7.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C8.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\I9.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C10.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\C11.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI12.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI13.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI14.java" -deprecation "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI141.java" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI142.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI15.java" 
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\UI16.java"  
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageName2\UI17.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageName2\UI18.java"
javac -d "C:\Android\Workspace\ProjectName\bin" -classpath "C:\Android\Workspace\ProjectName\bin" -bootclasspath "C:\Android\AndroidSDK\platforms\android-7\android.jar" "C:\Android\Workspace\ProjectName\src\com\Company\PackageName1\PackageNa

Step 3. Convert classes to Dalvik bytecodes

cd C:\Android\AndroidSDK\tools
dx --dex --output="C:\Android\Workspace\ProjectName\bin\classes.dex" --positions=lines C:\Android\Workspace\ProjectName\bin\

Step 4. Create unsigned APK

cd C:\Android\AndroidSDK\tools
aapt package -f -M "C:\Android\Workspace\ProjectName\AndroidManifest.xml" -S "C:\Android\Workspace\ProjectName\res" -j "C:\Android\Workspace\ProjectName\libs\JarName.jar" -A "C:\Android\Workspace\ProjectName\assets" -I "C:\Android\AndroidSDK\platforms\android-7\android.jar" -F "C:\Android\Workspace\ProjectName\bin\ProjectName.apk"

apkbuilder "C:\Android\Workspace\ProjectName\bin\ProjectName-debug.apk" -z "C:\Android\Workspace\ProjectName\bin\ProjectName.apk" -f "C:\Android\Workspace\ProjectName\bin\classes.dex" -rf "C:\Android\Workspace\ProjectName\src" -rj "C:\Android\Workspace\ProjectName\libs\JarName.jar"

Step 6. Generate a key
 
use key tool or use eclipe -> u r project Rclick -> AndroidTools -> export signed apk

Step 7. Sign APK

cd C:\Android\AndroidSDK\tools
jarsigner -keystore "C:\Android\ProjectName_key.key" -storepass "Password" -keypass "Password" -signedjar "C:\Android\APK\ProjectName_v1.0.apk" "C:\Android\Workspace\ProjectName\bin\ProjectName.apk" "Key-Alias"

예제 디렉토리 이미지 

설명:
음... 쿨하게 다 오픈하고싶지만... 어쩔수없네요... 자동배포를 위해 테스트한거였구요.

우선 리소스를 R.java로 만들고

javac로 R.java와 소스코드들 compile해준다. compile시 include관계 잘봐가면서 해줘야한다. 외부에서 끌어다 사용하는 jar있으면 표시해줘야 한다.

compile된 class파일들을 Dalvik으로 JVM용으로 변환 해준다.

aapt(Android Asset Packaging tool)을 이용하여 apk 만들고

apkbuilder로 unsigned apk를 만든다.

키는 keystore에서 만들거나 eclipe에서 제공하는 android tool을 사용한다 플젝 우클릭 안드 툴 익소포트 사인드 @#@가면 있다. 위에 명시해두었다...

마지막으로 unsigned apk와 key를 사용하여 배포한다.

 
신고
posted by Solver Full-stack Developer 2011.06.02 15:34
Animation slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.push_left_in);
신고
posted by Solver Full-stack Developer 2011.06.02 14:35
1.

u r manifest file

<activity android:name=".UICommand" android:screenOrientation="portrait"
   android:configChanges="keyboardHidden|orientation"></activity>


portrait, landscape, sensor... ect..


2.

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 




 
신고
posted by Solver Full-stack Developer 2011.06.01 18:35

@Override
 protected void onCreate(Bundle savedInstanceState) {

  gesdet = new GestureDetector(this,
    new GestureDetector.OnGestureListener()
{

     @Override
     public boolean onSingleTapUp(MotionEvent e) {
      // TODO Auto-generated method stub
      return false;
     }

     @Override
     public void onShowPress(MotionEvent e) {
      // TODO Auto-generated method stub
     }

     @Override
     public boolean onScroll(MotionEvent e1, MotionEvent e2,
       float distanceX, float distanceY) {
      // TODO Auto-generated method stub
      return false;
     }

     @Override
     public void onLongPress(MotionEvent e) {
      // TODO Auto-generated method stub
     }

     @Override
     public boolean onFling(MotionEvent e1, MotionEvent e2,
       float velocityX, float velocityY) {

      return false;
     }

     @Override
     public boolean onDown(MotionEvent e) {
      // TODO Auto-generated method stub
      return false;
     }
    });
 }

 @Override
 public boolean onTouchEvent(MotionEvent event) {
  return gesdet.onTouchEvent(event);
 }

ps. if you want doubletab event, you use GestureDetector.

신고
posted by Solver Full-stack Developer 2011.05.31 11:56
1.


2.

3.



your project or souce -> right click -> export -> click -> select u r file -> select the export destination -> finish or next -> end
신고
posted by Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.27 09:39

Bitmap src = BitmapFactory.decodeResource(getResources(), id);
src= Bitmap.createScaledBitmap(src, src_width, src_height,true);
신고
posted by Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.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 Solver Full-stack Developer 2011.05.12 10:20

 


신고
posted by Solver Full-stack Developer 2011.05.12 10:19

 


신고
posted by Solver Full-stack Developer 2011.05.12 10:18

 


신고

'Programming > WPF' 카테고리의 다른 글

WPF - Window Size 고정 시키기  (0) 2011.05.12
WPF - 투명화  (0) 2011.05.12
WPF - OpenFileDialog Sample  (0) 2011.05.12
WPF - MouseButtonEventArgs 에서 어느 버튼이 눌렸는지 확인  (0) 2011.05.12
WPF - Image change  (0) 2011.05.12
WPF - 실시간 width, height  (0) 2011.05.12
posted by Solver Full-stack Developer 2011.04.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
}

신고

티스토리 툴바