答案 0 :(得分:1)
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputSource);
String xml = doc.getDocumentElement().getTextContent();
传递showPopUpMenu(View);
你想要附加弹出窗口的地方吗?
View
答案 1 :(得分:0)
将此代码放在viewHolder类
中btnExpand.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(btnExpand.getContext(), itemView);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_Delete:
moveFile(recordName.getText().toString(), getAdapterPosition());
return true;
default:
return false;
}
}
});
popup.inflate(R.menu.second_contect);
popup.setGravity(Gravity.RIGHT);
try {
Field mFieldPopup=popup.getClass().getDeclaredField("mPopup");
mFieldPopup.setAccessible(true);
MenuPopupHelper mPopup = (MenuPopupHelper) mFieldPopup.get(popup);
mPopup.setForceShowIcon(true);
} catch (Exception e) {
}
popup.show();
}
});
你可以看到我的popupmenu