보이기
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월 6일 금요일
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);
}
}
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);
}
}
2011년 4월 18일 월요일
EditText Enter Key Event, Enter키(Done키) 보여주게 하기
setOnKeyListener 를 사용하면 Enter key 처리가 제대로 되지 않음.
edittext.setOnEditorActionListener(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if((actionId == EditorInfo.IME_ACTION_DONE)|| (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)){
.....
}
return false;
}
});
============================
EditText Enter or Done Key 등 개발자가 원하는 대로 보여주고자 할 때
edittext.setImeOptions(EditorInfo.IME_ACTION_NEXT)
edittext.setOnEditorActionListener(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if((actionId == EditorInfo.IME_ACTION_DONE)|| (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)){
.....
}
return false;
}
});
============================
EditText Enter or Done Key 등 개발자가 원하는 대로 보여주고자 할 때
edittext.setImeOptions(EditorInfo.IME_ACTION_NEXT)
2011년 4월 15일 금요일
2011년 4월 1일 금요일
Bitmap 테두리 Rounding 처리
public class BitmapUtils {
private static final int ROUND_DIPS = 10;
public static Bitmap getRoundedCornerBitmap(Context context, Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = convertDipsToPixels(context, ROUND_DIPS);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
public static int convertDipsToPixels(Context context, int dips) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dips * scale + 0.5f);
}
}
private static final int ROUND_DIPS = 10;
public static Bitmap getRoundedCornerBitmap(Context context, Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = convertDipsToPixels(context, ROUND_DIPS);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
public static int convertDipsToPixels(Context context, int dips) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dips * scale + 0.5f);
}
}
2011년 3월 2일 수요일
Android ProGuard 관련 글 모음
http://bit.ly/epHwwa
http://bit.ly/9GgKvl
http://bit.ly/dOudqP
프로가드 설치 : http://bit.ly/eYLxKl
안드로이드 프로가드 적용 : http://serlya.tistory.com/82
http://bit.ly/9GgKvl
http://bit.ly/dOudqP
프로가드 설치 : http://bit.ly/eYLxKl
안드로이드 프로가드 적용 : http://serlya.tistory.com/82
피드 구독하기:
글 (Atom)