Question

Hallo all,

I have a ListView, which contains an EditText in each of it's row. I also have an Array.The length of the Array==the Nr of the rows in the ListView.

I want to store the user input (the text in the EditText) to the Arrray. E.g, if i type some text in the EditText in the first row of the ListView, i want the text to be stored in Array[0]. But how can i detect to which row the EditText belongs to? I can detect the possition of the row if the row contains a RadioGroup, but not a EditText.

What if i first type some text in the EditText and sometime later i want to update mein Input? How can i update it?

Thanks a lot!

Was it helpful?

Solution

EditText extends Text which extends View. So you should be able to use ID's or Tag's don't you ?

OTHER TIPS

Alternatively, you can do something like this

//adapter's getView:
final int pos = positon;
EditText et = new EditText(context);

et.setOnKeyListener(new OnKeyListener() {

    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if ((event.getAction() == KeyEvent.ACTION_DOWN) && 
            (keyCode == KeyEvent.KEYCODE_ENTER)) 
        {
            vals[pos] = et.getText().toString();
            return true;
        }
        return false;
    }
});

warning* this comes from the head, not tested. no waranty provided.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top