2014-01-05 42 views
0

我是android開發新手。面對下面的問題,任何幫助讚賞。列表視圖頂部的按鈕不可點擊

我有列表視圖和頂部的三個按鈕。列表視圖項目是可點擊的,但沒有對按鈕點擊執行任何操作。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="50dip" > 

    <Button 
     android:id="@+id/sellers" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:focusable="false" 
     android:text="@string/sellers" /> 

    <Button 
     android:id="@+id/buyers" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:focusable="false" 
     android:text="@string/buyers" /> 

    <Button 
     android:id="@+id/addTicketButton" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:focusable="false" 
     android:text="@string/addTicket" 
     android:textSize="16sp" /> 
</LinearLayout> 

<ListView 
    android:id="@+id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFFFFF" > 
</ListView> 

這裏是控制文件

+0

這只是xml。你是否用代碼中的onClickListeners連接了這些按鈕? –

+0

正如我所看到的,在你的xml文件中沒有問題,並且按鈕點擊和Listview點擊之間也沒有關係。 請發佈您的完整代碼與onClick事件的按鈕,以便我或任何人在這裏可以幫助你。 – Swapnil

+0

@Nilesh你可以發佈你的java代碼嗎? – Mahfa

回答

0

變化android:layout_height="fill_parent"0dpwrap_content和所有的按鈕刪除android:focusable="false"

+0

嗨Kapil,我試過但不工作:( –

0

終於找到了上述問題的答案。

您必須在列表視圖的標題中添加按鈕。

//標題視圖列表LayoutInflater inflater = LayoutInflater.from(this);查看標題= inflater.inflate(R.layout.activity_ticket_list_header,null); Button addTicket =(Button)header.findViewById(R.id.addTicket); Button listBuyers =(Button)header.findViewById(R.id.listBuyers); Button listSellers =(Button)header.findViewById(R.id.listSellers); list.addHeaderView(報頭); list.addHeaderView(header);