-1
我想在popup菜單中顯示listview? 我建立initializeVars()的列表視圖 如何在我的showPopupMenu(視圖V)的iCall這種方法方法 告訴我這個計劃如何在彈出菜單中調用我自己的方法
public void initializeVars(){
lv_sample = (ListView)findViewById(R.id.lv_sample);
adapter = new ArrayAdapter<String>(this, R.layout.setlanguage, R.id.tv_content, values);
if(adapter==null)
return;
lv_sample.setAdapter(adapter);
}
private void showPopupMenu(View v){
PopupMenu popupMenu = new PopupMenu(MainActivity.this, v);
popupMenu.getMenuInflater().inflate(R.menu.main, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(MainActivity.this, item.toString(), Toast.LENGTH_LONG).show();
return true;
}
});
popupMenu.show();