<string name="speak">Sprechen</string>
<string name="nextWord">Nächstes Wort</string>
<string name="previousWord">Voriges Wort</string>
+ <string name="randomWord">Zufälliges Wort</string>
<!-- About dictionary. -->
<string name="dictionaryPath">Datei: %s</string>
<string name="speak">Speak</string>
<string name="nextWord">Next word</string>
<string name="previousWord">Previous word</string>
+ <string name="randomWord">Random word</string>
<!-- About dictionary. -->
<string name="dictionaryPath">File: %s</string>
List<RowBase> rowsToShow = null; // if not null, just show these rows.
+ final Random rand = new Random();
+
final Handler uiHandler = new Handler();
private final Executor searchExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
ImageButton languageButton;
SearchView.OnQueryTextListener onQueryTextListener;
- MenuItem nextWordMenuItem, previousWordMenuItem;
+ MenuItem nextWordMenuItem, previousWordMenuItem, randomWordMenuItem;
// Never null.
private File wordList = null;
defocusSearchText();
}
+ void onRandomWordButton() {
+ int destIndexEntry = rand.nextInt(index.sortedIndexEntries.size());
+ final Index.IndexEntry dest = index.sortedIndexEntries.get(destIndexEntry);
+ setSearchText(dest.token, false);
+ jumpToRow(index.sortedIndexEntries.get(destIndexEntry).startRow);
+ defocusSearchText();
+ }
+
// --------------------------------------------------------------------------
// Options Menu
// --------------------------------------------------------------------------
});
}
+ randomWordMenuItem = menu.add(getString(R.string.randomWord));
+ randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ onRandomWordButton();
+ return true;
+ }
+ });
+
application.onCreateGlobalOptionsMenu(this, menu);
{