0
I made a sample using this link: http://ericharlow.blogspot.in/2010/10/experience-android-drag-and-drop-list.html.
i am able to drag and drop objects from my list view.

Here is the code for my start and stop drag: 


public void onStartDrag(View itemView) {
            itemView.setVisibility(View.INVISIBLE);
            defaultBackgroundColor = itemView.getDrawingCacheBackgroundColor();
            // itemView.setBackgroundColor(backgroundColor);
            mChangeButton = (Button) findViewById(R.id.change_btn);
            Button iv = (Button) itemView.findViewById(R.id.delete_btn);
            if (iv != null)
                iv.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onStopDrag(View itemView) {
            itemView.setVisibility(View.VISIBLE);
            // itemView.setBackgroundColor(defaultBackgroundColor);
            mChangeButton = (Button) findViewById(R.id.change_btn);
            Button iv = (Button) itemView.findViewById(R.id.delete_btn);
            if (iv != null)
                iv.setVisibility(View.VISIBLE);
        }

我的问题是如何为我的 Button iv 设置 OnClickListener?它不允许我设置 onDrag。提前致谢

4

1 回答 1

0

1)创建一个侦听器对象 2)创建一个需要定义侦听器的方法 3)在拖动集侦听器内部这可能有效:)

OnClickListner onclicklistner;
.....
void listner()
{
onclicklistner=new OnclickListner({
void onClick(v.getid){...}
});
}
....
button.setoOnClickListener(onclicklistener);`
于 2012-04-25T11:34:37.107 回答