2

This is my headache!

My app is a language dictionary. Its database is stored in the SQLite database saved in SDcard. I assume when a user like a word s/he will save it to the Favourite list. I decide to code to save such favourite words to the XML file (SharedPreferences) in which they appear like the below:

<string name="favourite">dict_name::149271::go,dict_name::25481::back,dict_name::184774::jet</string>
<boolean name="saveFavourite" value="true" />

The string "favourite" begins with the dictionary name (database name), then the word ID (number), and the word itself. The Favourite list is successfully displayed as illustrated in the image below.

I use the following code to bind the Favourite items with their definitions in the SQLite database:

mLSTFavourite.setOnItemClickListener(new AdapterView.OnItemClickListener() 
    {
         public void onItemClick(AdapterView<?> listView, View itemView, int itemPosition, long itemId)
            {           
            Intent launchActivity = new Intent(FavouriteView.this, ContentView.class);
            startActivity(launchActivity);
        }
    });

But the problem is that the app cannot find out the definition of each of the words in the shown Favourite list.

I want the definition of the word (item) in the Favourite list to be displayed when it is clicked. What should I do now?

Can you guys give a little help?

Thank you very much.

Community
  • 1
  • 1
Niamh Doyle
  • 1,909
  • 7
  • 30
  • 42
  • Do you want to show the definition of that favorite word in a different class `ContentView`?Or in the list of favorites? – user Mar 01 '12 at 09:14
  • you will have to construct a custom adapter class to populate that listview.. – Hiral Vadodaria Mar 01 '12 at 09:14
  • Thanks. The `ContentView` is used to display all definitions. There's no problem when the listview is populated in the `MainActivivity`. – Niamh Doyle Mar 01 '12 at 09:18
  • I think you have to better explain what are you doing. You have a different activity `FavoriteView` where you show a list of favorite words that come from the preferences? What adapter do you use in this activity, how exactly do you get the values from the preferences, do you want the definition in the same list from FavoriteView along side the favorite words? – user Mar 01 '12 at 09:51
  • @slukian: Many thanks for your time. In fact, I asked the similar question but no answer has been made up to to now. My explanation to what I am doing can be found in the link below. Can you please have a look at the [Favourite class here](http://stackoverflow.com/questions/9477970/favourite-content-is-not-shown-correctly-on-webview)? – Niamh Doyle Mar 01 '12 at 10:09
  • I've seen that question. Have you tested and see what ID you get from the `Favorite` class when you send the results back to `ContentView`? For example , if you select the second favorite word, is the id you receive in the `ContentView` class from the intent the id you you have in the preferences for word 2? – user Mar 01 '12 at 10:44
  • Well thanks, the problem is: it doesn't mind which words I choose (word1, word2...), the ID I receive in the ContentView is always the word I've just added to the Favourite list. May we chat for a while in the Chat Room? – Niamh Doyle Mar 01 '12 at 10:58
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/8387/discussion-between-slukian-and-niamh-doyle) – user Mar 01 '12 at 11:10

0 Answers0