开发者

Custom Title Bar Button in ListActivtiy

I want to have an CustomTitle bar with some buttons in it within the ListActivity. Uptill now I am successful in displaying the title bar with some buttons. But I cannot handle the event of click on those buttons. Following is my code:

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);


        }
}
}

When I add the clickListener for the button it gives me error

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

I think its because of I have a different Listener for the ListActivity and might be its conflicting with this one. Also can it be defined in the OnResume method?

Is there any solution with this?

Thanks in advance.


It looks like you have imported the wrong OnClickListener. Change:

import android.content.DialogInterface.OnClickListener;

to

import android.view.View.OnClickListener;

That should do the trick.


You imported DialogInterface.OnClickListener; instead of view.OnClickListener; import android.view.View.OnClickListener; and you will use the correct listener.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜