簡體   English   中英

ListActivtiy中的自定義標題欄按鈕

[英]Custom Title Bar Button in ListActivtiy

我想在ListActivity中有一個CustomTitle欄,其中帶有一些按鈕。 到目前為止,我已經成功顯示了帶有一些按鈕的標題欄。 但是我無法處理單擊這些按鈕的事件。 以下是我的代碼:

import android.content.DialogInterface.OnClickListener;

public class ProfileListView extends ListActivity {

    boolean done;

    @Override
    protected void onResume() {
        super.onResume();
        System.out.println("OnResume ProfileListView");
        this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.profile_list);
        this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.maintitlebar);


        }
}
}

當我為按鈕添加clickListener時,出現錯誤

The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})

我認為這是因為我對ListActivity具有不同的偵聽器,可能與它與此沖突。 還可以在OnResume方法中定義它嗎?

有什么解決辦法嗎?

提前致謝。

好像您導入了錯誤的OnClickListener。 更改:

import android.content.DialogInterface.OnClickListener;

import android.view.View.OnClickListener;

這應該夠了吧。

您導入了DialogInterface.OnClickListener; 而不是view.OnClickListener; 導入android.view.View.OnClickListener; 您將使用正確的偵聽器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM