How to use custom front at SimpleCursorAdapter for a list view at Searchable Dictionary App??? please help me

Posted by user1877275 on Stack Overflow See other posts from Stack Overflow or by user1877275
Published on 2012-12-04T23:00:20Z Indexed on 2012/12/04 23:03 UTC
Read the original article Hit count: 146

I am new in android. this is my frist project.I am tring to make a Name dictionary in bangla so i need to change the front. I already add front into the asset folder..

private void showResults(String query) {

    Cursor cursor = managedQuery(DictionaryProvider.CONTENT_URI, null, null,
                            new String[] {query}, null);

    if (cursor == null) {
        // There are no results
        mTextView.setText(getString(R.string.no_results, new Object[] {query}));
    } else {
        // Display the number of results
        int count = cursor.getCount();
        String countString = getResources().getQuantityString(R.plurals.search_results,count, new Object[] {count, query});
        mTextView.setText(countString);

        // Specify the columns we want to display in the result
        String[] from = new String[] { DictionaryDatabase.KEY_WORD,
                                       DictionaryDatabase.KEY_DEFINITION };

        // Specify the corresponding layout elements where we want the columns to go
        int[] to = new int[] { R.id.word,
                               R.id.definition };




        // Create a simple cursor adapter for the definitions and apply them to the ListView          

        SimpleCursorAdapter words = new SimpleCursorAdapter(this, R.layout.result, cursor, from, to);


        mListView.getAdapter();

        // Define the on-click listener for the list items
        mListView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // Build the Intent used to open WordActivity with a specific word Uri
                Intent wordIntent = new Intent(getApplicationContext(), WordActivity.class);
                Uri data = Uri.withAppendedPath(DictionaryProvider.CONTENT_URI,
                                                String.valueOf(id));
                wordIntent.setData(data);
                startActivity(wordIntent);
            }
        });
    }     
}

© Stack Overflow or respective owner

Related posts about android

Related posts about simplecursoradapter