【发布时间】:2014-12-27 05:50:43
【问题描述】:
尝试在弹出窗口内设置列表视图的项目选定侦听器时遇到一些问题。这是我的代码:
private void openPopUp() {
LayoutInflater layoutInflater = (LayoutInflater) getActivity()
.getBaseContext().getSystemService(
context.LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.event_attendee_pop,
null);
llAttendeeList = (LinearLayout) popupView
.findViewById(R.id.llAttendeeList);
attendeeListView = (ListView) popupView.findViewById(R.id.attendeelistview);
final PopupWindow popupWindow = new PopupWindow(popupView,
LayoutParams.WRAP_CONTENT, 450);
popupWindow.showAtLocation(popupView, Gravity.BOTTOM, 0, 70);
mAdapter = new ListAdapter(getActivity());
attendeeListView.setAdapter(mAdapter);
attendeeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View item,
int position, long id) {
Log.i("HIIII","HIII");
String telNo = attendeeList.get(position)
.getTelNo();
Intent intentDialer = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:1234-5678"));
startActivity(intentDialer);
}
});
}
When the item from listview inside a popup window is selected, I wanted to open a dialer page.但是,当我通过放置一条日志消息对此进行测试时,当我从列表视图中选择项目时,它不会执行在项目上选择的侦听器。
有什么想法吗?提前致谢。
【问题讨论】:
-
你的适配器有数据吗?您将数据放入适配器的什么位置??
-
@Rohit5k2 让我更新一下我的问题
标签: java android listview layout-inflater