2012-11-26 4 views
3

문자열 파일에서 가져온 텍스트를 보려면 텍스트 상자를 사용했습니다. 나는 사용자가 원하면 edittext에서 텍스트를 복사 할 기회를주고 싶다. 완전 복사 또는 부분 복사 일 수 있습니다.longpress android 용 키보드를 비활성화하는 방법

긴 프레스 이벤트가 발생하면 복사 메시지가 나옵니다. 그러나 vertual 키보드도 나온다. 나는 그것을 숨길 수 없다. 여러 가지 방법을 시도했으며, 여기 내 XML 코드입니다.

<EditText 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginBottom="23dp" 
    android:background="@null" 
    android:editable="false" 
    android:gravity="right" 
    android:inputType="none" 
    android:padding="@dimen/padding_maintextview" 
    android:text="@string/text" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

여기에 자바 코드가 있습니다.

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(tvchange12.getWindowToken(), 0); 
tvchange12.onCheckIsTextEditor(); 

여기에 긴 프레스 vertual 키보드를 숨기도록 도와 주시기 바랍니다 MEDIT 클래스

public class MEditText extends EditText { 
    public MEditText(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     // TODO Auto-generated constructor stub 
    } 

    @Override 
    public boolean onCheckIsTextEditor() { 
     return false; 
    } 
} 

입니다.

+0

이것은 표준 동작입니다. 더 나은 그것을 억제하지 마십시오. 예 - 사용자가 복사를 위해 텍스트를 삭제하거나 바꾸기를 원할 수 있습니다. – mihail

+0

하지만 난 단지 – kiriappa

답변

0

텍스트를 편집 할 필요가없는 경우이 사용자는 키보드없이 텍스트를 선택하고 복사 할 수 있습니다.

+0

textview 지원이 11에서 API를 복사 지원 싶습니다. 나는 minimus SDK를 8 사용합니다. 따라서 그것은 wouldnt 작업 – kiriappa

관련 문제