2011-04-13 64 views
1

我想在ListActivity内的某个按钮中包含CustomTitle栏。 直到现在,我成功地用一些按钮显示标题栏。 但我无法处理点击这些按钮的事件。 以下是我的代码:ListActivtiy中的自定义标题栏按钮

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方法中定义它吗?

有没有解决方法?

在此先感谢。

回答

2

它看起来像你导入了错误的OnClickListener。更改:

import android.content.DialogInterface.OnClickListener; 

import android.view.View.OnClickListener; 

这应该做的伎俩。

1

您导入的DialogInterface.OnClickListener;而不是view.OnClickListener;导入android.view.View.OnClickListener;,您将使用正确的侦听器。