Note that there are some explanatory texts on larger screens.

plurals
  1. POPut the text of a row of a listview in a variable
    primarykey
    data
    text
    <p>In the application I'm doing, I'm trying to make it do something different depending on the text so I have a code which supposedly retrieves the texto of the row I clicked and then with an if else it tells the program to do something different depending on the code.</p> <pre><code>@Override protected void onListItemClick(ListView l, View v, int position, long id) { int selectionRowID = (int) this.getSelectedItemId(); String selectedFileString = this.directoryEntries.get(selectionRowID); if (selectedFileString.equals(".")) { this.browseToSD(); } else if(selectedFileString.equals("..")) { this.upOneLevel(); } else { File clickedFile = null; clickedFile = new File(this.currentDirectory.getAbsolutePath() + this.directoryEntries.get(selectionRowID)); if(clickedFile != null) this.browseTo(clickedFile); } } </code></pre> <p>But it doesn't work, this: "selectedFileString.equals(".")" is always TRUE so it always does browseToSD, but sometimes the text is ".." and most of the times it's something completely different so the app doesn't do what it's suppose to do. I tried to change the code to this:</p> <pre><code>@Override protected void onListItemClick(ListView l, View v, int position, long id) { ListView lv = getListView(); ListAdapter list_adapter = lv.getAdapter(); TextView var_x = (TextView) list_adapter.getView(0,null,null); if (var_x.equals(".")) { this.browseToSD(); } else if(var_x.equals("..")) { this.upOneLevel(); } else { File clickedFile = null; clickedFile = new File(this.currentDirectory.getAbsolutePath() + this.directoryEntries.get(selectionRowID)); if(clickedFile != null) this.browseTo(clickedFile); } } </code></pre> <p>But this doesn't work either, "var_x.equals(".")" and "var_x.equals("..")" are always false. I'm really new to programming with Java and Android so I don't have a clue why it doesn't work, any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload