Find a lot of articles on the web, that is in the XML file set TextView focus is false, it is nonsense, so even the text can not input, what is the use of
Search online without results, use Java code to control the ListView Longclick method, to implement pop-up replication and delete ListView methods
Customizing a Popwindow
private void Initpopupwindow (Layoutinflater inflater) {
View view = Inflater.inflate (r.layout.pop_item_layout, NULL);
Popupwindow = new Popupwindow (view, 100, 50);
popupwindow.setwidth (layoutparams.wrap_content);
popupwindow.setheight (layoutparams.wrap_content);
Copytv = (TextView) View.findviewbyid (R.ID.POP_COPY_TV);
Deletetv = (TextView) View.findviewbyid (R.ID.POP_DELETE_TV);
}
and write a listening method on your own.
Class Tvontouch implements Ontouchlistener {
Private Context Mcontext;
private int mposition;
Public Tvontouch (context context, int position) {
TODO auto-generated Method Stub
This.mcontext = context;
This.mposition = position;
}
@Override
public boolean OnTouch (View V, motionevent event) {
TODO auto-generated Method Stub
if (v.getid () = = R.id.pop_copy_tv) {
TextView TV = (TextView) v;
if (event.getaction () = = Motionevent.action_down) {//Press
Tv.settextcolor (0xff00cd66);
} else if (event.getaction () = = motionevent.action_up) {//Bounce up
Tv.settextcolor (0xFFFFFFFF);
Com.robot.utils.TextManager.copyText (Mcontext, Mdatas.get (mposition). getmsg ());
Toast.maketext (Mcontext, "Copy succeeded", Show_time). SHOW ();
if (Popupwindow! = null) {
Popupwindow.dismiss ();
}
}
} else {
TextView TV = (TextView) v;
if (event.getaction () = = Motionevent.action_down) {//Press
Tv.settextcolor (0xff00cd66);
} else if (event.getaction () = = motionevent.action_up) {//talk about
Tv.settextcolor (0xFFFFFFFF);
Mdatas.remove (mposition);
Notifydatasetchanged ();
Toast.maketext (mcontext, "delete succeeded", Show_time). SHOW ();
if (Popupwindow! = null) {
Popupwindow.dismiss ();
}
}
}
return true;
}
}
Finally, we add a listener to the GetView.
ViewHolder.content.setOnLongClickListener (New Onlongclicklistener () {
@Override
public boolean Onlongclick (View v) {
TODO auto-generated Method Stub
Showpop (v);
Copytv.setontouchlistener (New Tvontouch (Mcontext, position));
Deletetv.setontouchlistener (New Tvontouch (Mcontext, position));
return false;
}
});
The solution to the focus of Android's ListView and TextView