2017-08-25 73 views
0

我跟着這個url link 我成功地做到了這一點,但文本框沒有響應觸摸。 我想寫在這個文本框中並獲取位置。我只需要知道如何讓文本框響應我的觸摸。 我該怎麼做?TextBox over MapFragment Clickable

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="fill_parent" 
tools:context=""> 


<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 

    /> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/ll" 
    android:orientation="horizontal" 
    android:layout_alignParentTop="true"> 
    <TextView 
     android:layout_width="300dp" 
     android:layout_height="50dp" 
     android:layout_margin="5dp" 
     android:background="@color/colorPrimary" 
     android:clickable="true" 
     /> 

</LinearLayout> 

+0

要補充的onclicklistener的看法? – ingyesid

+0

它不會只是沒有Java代碼響應? –

+1

@ShubhamAgarwalBhewanewala textView沒有Java代碼沒有響應。我猜你需要在這裏使用EditText,這會給你選擇輸入一些值 – Arshad

回答

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 

     android:orientation="horizontal"> 

     <EditText 
      android:id="@+id/editText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="4" 
      android:hint="Search Location Here" /> 


     <Button 
      android:id="@+id/search_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.5" 
      android:onClick="onMapSearch" 
      android:text="Search" /> 

    </LinearLayout> 

    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.viralandroid.googlemapsandroidapi.MapsActivity" /> 

</LinearLayout> 

上MapFragment文本框..