android - Listview 中的项目仅在单击文本时才可选择

android - Listview 中的项目仅在单击文本时才可选择

public void onClick(View arg0) {

final Dialog dialog = new Dialog(Hero.this);

ListView list = new ListView(Hero.this);

final ArrayList spells = new ArrayList();

for (int i = 0; i < MainActivity.charSpells.size(); i++){

if (MainActivity.charSpells.get(i).getType() == Spell.SPELL){

spells.add(MainActivity.charSpells.get(i));

}

}

list.setAdapter(new ArrayAdapter(Hero.this, R.layout.row, spells));

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

dialog.setContentView(list);

dialog.setCanceledOnTouchOutside(true);

dialog.show();

list.setOnItemClickListener(new OnItemClickListener()

{

@Override

public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {

spell1.setText(spells.get(arg2).getSc());

MainActivity.spells[0] = spells.get(arg2);

dialog.dismiss();

}

});

}

我制作了这个包含 ListView 的对话框,但是当您单击文本时只能选择项目,而不是像应该的那样在整行上选择项目。谁能找到我的错误?

编辑:

好的,解决了,我使用了一个构建器来制作对话框:

https ://stackoverflow.com/a/6157258/2468567

相关推荐

cad多线样式怎么设置?三个步骤详细讲解 bt365手机版
暴扣哥个人资料哪里人 原名王浩轩家庭背景怎么出道的? 365bet游戏平台
几种常见的容器 365bet游戏平台

几种常见的容器

07-03 👁️ 8404