我在弹出菜单中有一个列表视图,它显示正确,但 onitemclicklistener 不适用于该列表视图。
public String[] pop={"a","b","c","d"};
我的适配器
final ArrayAdapter<String> popadapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, pop);
public void onClick(View v) {
popUpView = getLayoutInflater().inflate(R.layout.popup,
null); // inflating popup layout
mpopup = new PopupWindow(popUpView, 250, 140);
mpopup.setAnimationStyle(android.R.style.Animation_Dialog);
mpopup.showAtLocation(popUpView, Gravity.CENTER, 0, 0);
mpopup.setTouchable(true);
mpopup.setFocusable(true);
mpopup.setOutsideTouchable(true);
mpopup.setContentView(popUpView);
ListView lv=(ListView)popUpView.findViewById(R.id.listView1);
lv.setAdapter(popadapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
mpopup.dismiss();
Toast.makeText(getApplicationContext(),
"ok", Toast.LENGTH_SHORT)
.show();
// TODO Auto-generated method stub
}
});
我找不到解决方案