카테고리 없음2017. 10. 14. 10:15
반응형

안드로이드 화면 회전시 내용 refresh  방지 


AndroidManifest.xml 파일내에


    <application 내에 추가 해주 세요


            android:configChanges="orientation|screenSize"



반응형
Posted by Dream Come True
카테고리 없음2017. 10. 13. 13:50
반응형
edt1 = (EditText) findViewById(R.id.editText);
edt1.addTextChangedListener(new CustomTextWatcher(edt1));



클래스 생성
=======================================================



import android.text.Editable;
import android.text.Selection;
import android.text.TextWatcher;
import android.widget.EditText;

import java.text.DecimalFormat;

/**
 * Created by buster on 17. 10. 13.
 * 천단위 컴마 붙이기
 *
 */
public class CustomTextWatcher implements TextWatcher {
    @SuppressWarnings("unused")
    private EditText mEditText;
    String strAmount = ""; // 임시 저장값 (콤마)

    public CustomTextWatcher(EditText e) {
        mEditText = e;
    }

    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {    //텍스트가 변경될때마다 실행
        if (!s.toString().equals(strAmount)) { // StackOverflow 방지
            strAmount = makeStringComma(s.toString().replace(",", ""));
            mEditText.setText(strAmount);
            Editable e = mEditText.getText();
            Selection.setSelection(e, strAmount.length());
        }
    }

    protected String makeStringComma(String str) {    // 천단위 콤마 처리
        if (str.length() == 0)
            return "";
        long value = Long.parseLong(str);
        DecimalFormat format = new DecimalFormat("###,###");
        return format.format(value);
    }

}
======================================================
계산식에 , 마 제거 해야 정상적인 계산이 이루어 진다.

double input1 = Double.valueOf(edt1.getText().toString().replace(",",""));


반응형
Posted by Dream Come True
IT/android2017. 10. 9. 12:10
반응형


첫번째 방법 엑티비티 소스에 골라서 추가


setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);  //강제 가로

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  //강제 세로

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); //센서대로



두번째 방법

androidmanifest.xml 수정 방법


android:screenOrientation="portrait"


android:screenOrientation="landscape"

반응형
Posted by Dream Come True
카테고리 없음2017. 10. 3. 02:13
반응형



안드로이드 webview  화면 회전시 리로드 되거나 앱이 죽을때 


manifest -> <activity  -> 다음을 추가 하라


android:configChanges="orientation|screenSize"


반응형
Posted by Dream Come True