2011년 5월 17일 화요일

TabWidget의 구분선 적용

mTabHost.getTabWidget().setDividerDrawable(R.drawable.divider_vertical_dark);

소프트 키보드가 열린상태에서 BACK KEY 제어

public class CustomEditText extends EditText {

public CustomEditText(Context a_context) {
super(a_context);

}

public CustomEditText(Context a_context, AttributeSet a_attributeSet) {
super(a_context, a_attributeSet);
}

public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true; // 사용자가 override한 함수 사용
}
}
return super.onKeyPreIme(keyCode, event); // 시스템 default 함수 사용

}
}

2011년 5월 11일 수요일

ListView UI 관련 팁

[리스트 라인 관련]
android:divider="#292929"
android:divider="@drawable/list_column_line"
android:dividerHeight="1px"

[리스트 쉐도우 영역 없애기]
android:fadingEdge="none"

[리스트 스크롤 없애기]
android:scrollbars="@null"

2011년 5월 6일 금요일

키보드 보이기, 숨기기

보이기
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

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

2011년 5월 3일 화요일

overscrolling in Android 2.3

AbsListView
setOverScrollMode(int mode)

View.OVER_SCROLL_ALWAYS
View.OVER_SCROLL_IF_CONTENT_SCROLLS
View.OVER_SCROLL_NEVER

=======================================

http://jasonfry.co.uk/?id=26
http://jasonfry.co.uk/?id=27


public class BounceListView extends ListView{
  private static final int MAX_Y_OVERSCROLL_DISTANCE = 200;  
  private Context mContext;
private int mMaxYOverscrollDistance;

public BounceListView(Context context){
super(context);
mContext = context;
initBounceListView();
}

public BounceListView(Context context, AttributeSet attrs){
super(context, attrs);
mContext = context;
initBounceListView();
}

public BounceListView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
mContext = context;
initBounceListView();
}

private void initBounceListView(){
//get the density of the screen and do some maths with it on the max overscroll distance
//variable so that you get similar behaviors no matter what the screen size

final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
    final float density = metrics.density;
      
mMaxYOverscrollDistance = (int) (density * MAX_Y_OVERSCROLL_DISTANCE);
}

@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent){
//This is where the magic happens, we have replaced the incoming maxOverScrollY with our own custom variable mMaxYOverscrollDistance;
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, mMaxYOverscrollDistance, isTouchEvent);
}
}

스크롤 버튼

setFastScrollEnabled(true) 로 설정하면 된다.