2016-09-18 9 views
2

私はEditTextを使用していますが、Activityが起動したときにはEditTextは既にフォーカスされています。私はフォーカスを削除し、クリック時に編集可能にしたい。EditTextからフォーカスを削除して編集可能にしておきます

ここに私の編集テキストのコードです。

<EditText 
      android:id="@+id/et_HotelLocation" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="8dp" 
      android:drawableLeft="@drawable/ic_edit_location_black_24dp" 
      android:drawablePadding="8dp"/> 

答えて

1

あなたは正確にあなたのEditTextの上に維持し、その後nextFocusUpとnextFocusLeftを使用する必要があり、それ以下のようにあなたはダミーのレイアウトを作成することができます示されるように。

<LinearLayout 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:layout_width="0px" 
      android:layout_height="0px"/> 

     <EditText 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="8dp" 
      android:id="@+id/et" 
      android:drawablePadding="8dp" 
      android:nextFocusUp="@id/et" 
      android:nextFocusLeft="@id/et" 
      app:met_floatingLabel="normal" /> 
0

あなたのエディットテキストは、リニアレイアウト内にある場合は、この質問はすでに持っているこの

<LinearLayout 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

<EditText 
      android:id="@+id/et_HotelLocation" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="8dp" 
      android:drawableLeft="@drawable/ic_edit_location_black_24dp" 
      android:drawablePadding="8dp"/> 
</LinearLayout> 
0

のように行うことができますテキストの編集

android:focusable="true" 
android:focusableInTouchMode="true" 

の親のレイアウトに次の2つのプロパティを追加します。応答しましたhere

もこれを試してみてください - this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

をそれ以外の場合は、マニフェストファイルの活動に宣言 -

<application android:icon="@drawable/icon" 
      android:label="@string/app_name"> 
<activity android:name=".Main" 
    android:label="@string/app_name" 
    android:windowSoftInputMode="stateHidden" 
    > 
関連する問題