我的listview
项目也没有显示弹出菜单,它们没有被点击..这是我的代码,我需要帮助。
public class AddMovieToList extends AppCompatActivity {
MovieDbHelper helper;
MyListAdapter adapter;
ListView myDataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
helper = new MovieDbHelper(getApplicationContext());
setContentView(R.layout.activity_addtolist);
myDataList = (ListView) findViewById(R.id.addToList_listView);
ArrayList<MovieModel> getInfos = helper.getMovieInfo();
myDataList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
PopupMenu popupMenu = new android.widget.PopupMenu(getApplicationContext(),view);
popupMenu.getMenuInflater().inflate(R.menu.popup_menu, popupMenu.getMenu());
popupMenu.show();
return true;
}
});
if(adapter == null){
adapter = new MyListAdapter(getBaseContext(),R.layout.addlist_layout_type,getInfos);
myDataList.setAdapter(adapter);
}else{
adapter.clear();
adapter.addAll(getInfos);
adapter.notifyDataSetChanged();
}
}