2016-09-14 33 views
-1

這是我的佈局文件代碼按鈕不可點擊的滾動視圖Android

一切工作正常,但按鈕不可點擊。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/maps" 
    android:gravity="center_horizontal" 
    android:orientation="vertical"> 
    <include layout="@layout/custom_actionbar" /> 
    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:orientation="vertical" 
      android:paddingBottom="30dp"> 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/pf_color" 
       android:paddingLeft="20dp" 
       android:paddingRight="20dp" 
       android:text="TRACK" 
       android:textSize="20dp" /> 

     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

請幫忙解決這個問題。我很感謝你。 我無法理清什麼是實際問題。我試過android:clickable =「true」但仍然是相同的問題 在此先感謝。

+0

你設置了clicklistener這個按鈕在java文件 –

+0

我們可以有活動嗎? – BAAAZINGA

+0

加入onCLickListener之後是工作,但不作爲按鈕 –

回答

0

不要忘記設置onCLickListener

確實烏爾主類實現onClickListener如果是這樣做的:

public void onClick(View v) { 
     switch (v.getId()) { 
     case: R.id.YOURBUTTON: 
      //do ur stuff 
     break; 
     default: 
      //todo when the screen is touched 
     break; 
    } 
} 

我無法找到你的按鈕ID順便說一句這就是爲什麼我把它叫做YOURBUTTON

+0

的感覺加入onCLickListener之後是工作,但不作爲button.no連鎖反應沒有按鈕,它充當的感覺文字clickabe –

+0

我編輯了我的原始帖子:) – BAAAZINGA

0

嘗試把這個在XML中插入您的按鈕:

android:onClick="myClickFunction"

因此,這將是:

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/pf_color" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp" 
    android:text="TRACK" 
    android:textSize="20dp" 
    android:onClick="myClickFunction" /> 

然後把這個在你的活動:

public void myClickFunction(View v) { 
    // do stuff when clicked 
} 
0

你使用最新的支持庫,com.android.support:support-v4:24.0.0?我認爲這是一個錯誤,因爲我有同樣的問題..

+0

是的,我有最新的圖書館 –

+0

我有與按鈕相同的問題,我發現它3天前。我尋找最新的圖書館的任何錯誤,但我沒有找到任何東西。它很煩人.. –

相關問題