2017-06-18 3 views
-2

EditTextの をクリックすると、その特定のフォーカスが当たったときに特定の操作が実行されるようなボタンまたはビューを作成したいEditText私はそれがどのように呼び出されたのか、それを行う3Dパーティーライブラリがあるかどうかわかりません。他のビューの上にフローティングボタン - Android

+1

は、あなたがちょうどあなたが実際に欲しいものを詳しく説明するために、画像や何かを投稿することができますか? –

答えて

0

これは、RelativeLayoutsがフォーカスを持っているビューの上にビューを置くことができるので、ここでは大きな役割を果たします。逆もまた同様です。だから、最初のあなたはFABを使用するようにローカルのbuild.gradleファイルにAndroidの最新のサポート設計ライブラリをコンパイルして、レイアウトファイルのために、このような何かをしたい:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    tools:context="com.davenotdavid.stackoverflow.MainActivity"> 

    <EditText 
     android:id="@+id/et1" 
     android:hint="HINT..." 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <EditText 
     android:id="@+id/et2" 
     android:hint="HINT..." 
     android:layout_below="@id/et1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <EditText 
     android:id="@+id/et3" 
     android:hint="HINT..." 
     android:layout_below="@id/et2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" /> 

</RelativeLayout> 

...とFAB場合、おそらくテストあなたのonCreateに(ポップアップのEditTextのキーボードではなく)トーストメッセージを表示することにより、焦点のEditTextの上に焦点を当てています()としては、次のとおりです。

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      Toast.makeText(MainActivity.this, "FAB clicked", Toast.LENGTH_SHORT).show(); 
     } 
    }); 
} 
+1

ありがとう!あなたは私が必要な方向に私を指摘:) –

関連する問題