I have sort of a file manager. It displays files in a ListView. Each of those ListViews has a custom footer – a button, which is defined in a xml file. Pressing a button allows user to chose a file from the “downloads” directory and copy it to the folder where the button was pressed. This is implemented through the AlertDialog. So by clicking the option from the dialog I get a path of a file that should be copied.
Now, how do I get the location from which my button was pressed? Can I somehow pack some sort of data in my button on its creation so that later when it is pressed I could identify its initial location?
there are many ways to achieve that. you can create a separate OnClickListener for each button as JaLoveAst1k proposes. you could also add some information to the buttons’s tag (setTag()) and get it back in the onClick() function. Yet another way would be to have a
Hashtable<Button, String>where you store your string informaton relative to the Button.