0
    public void onClick(View arg0) {
        final Dialog dialog = new Dialog(Hero.this);
        ListView list = new ListView(Hero.this);

        final ArrayList<Spell> spells = new ArrayList<Spell>();
        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<Spell>(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();
                    }
          });

        }

I made this Dialog which contain a ListView, but the items can ony be selected when you click on the text and not, like it should be, on the whole row. Can anyone find my mistake?

EDIT:

OK, solved it, I used a builder to make the dialog: https://stackoverflow.com/a/6157258/2468567

Community
  • 1
  • 1
Aeres
  • 7
  • 4

2 Answers2

1

If that's happening, I'm assuming your TextView resource must be set to wrap_content for both height/width, which would mean the only touchable area is where the actual text is.

Try changing their values in the XML to fill_parent (or a fixed size or whatever you're doing). Then adjust the android:gravity to adjust where the text is placed within the View.

Recap:

android:layout_width="fill_parent"
android:layout_height="fill_parent
android:gravity="center"
Cruceo
  • 6,763
  • 2
  • 31
  • 52
0

Try to make the width bigger then the screen on the TextView list.xml

android:layout_width="1000dp"