gpt4 book ai didi

java - ListView onItemSelected 监听器不工作

转载 作者:行者123 更新时间:2023-11-30 11:10:31 27 4
gpt4 key购买 nike

尝试在弹出窗口中设置 ListView 的项目选定监听器时,我遇到了一些问题。这是我的代码:

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);
}
});
}

当从弹出窗口中的 ListView 中选择项目时,我想打开一个拨号页面。但是,当我通过放置日志消息对此进行测试时,当我从 ListView 中选择项目时,它不会执行项目选择的监听器。

有什么想法吗?提前致谢。

最佳答案

您必须使用另一个带有 boolean 参数的构造函数,该参数允许聚焦到 PopupWindow 项目:

public PopupWindow (View contentView, int width, int height, boolean focusable)

final PopupWindow popupWindow = new PopupWindow(popupView,LayoutParams.WRAP_CONTENT,450,true);

关于java - ListView onItemSelected 监听器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27664774/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com