listview +icons+ sqlite

by carmelo » Tue, 23 Mar 2010 01:51:52 GMT


Sponsored Links
 Hi! I'm trying to read datas from a db, display them into a list with
icons ( not fixed but changing in base of the value read in the db). I
know how to do this thing, reading values from a simple array:

public class DynamicDemo extends ListActivity {
TextView selection;
String[] items={"cinema", "cinema", "sport", "sport", "music", "art",
"shopping", "shopping", "music"};

//@Override
public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                setContentView(R.layout.main);
                setListAdapter(new IconicAdapter());
                selection=(TextView)findViewById(R.id.selection);
}


class IconicAdapter extends ArrayAdapter {
                IconicAdapter() {
                super(DynamicDemo.this, R.layout.row, items);
}

//@override
public View getView(int position, View convertView, ViewGroup parent)
{

        LayoutInflater inflater=getLayoutInflater();
        View row=inflater.inflate(R.layout.row, parent, false);

        //set view for text
        TextView label=(TextView)row.findViewById(R.id.label);
        label.setText(items[position]);

        //set view for icon
        ImageView icon=(ImageView)row.findViewById(R.id.icon);

        //select correct icon
        if (items[position].equals("cinema")) {
                icon.setImageResource(R.drawable.cinema);
        }
        if (items[position].equals("sport")){
                icon.setImageResource(R.drawable.sport);
        }
        if (items[position].equals("art")){
                icon.setImageResource(R.drawable.art);
        }
        if (items[position].equals("shopping")){
                icon.setImageResource(R.drawable.shopping);
        }
        if (items[position].equals("music"))    {
                icon.setImageResource(R.drawable.music);
        }
return(row);
}
}
}

But I cannot find a way to do the same thing using the cursor with the
result of the query. Anyone can help?
thanks!

--



Other Threads

1. Google WebElements Discussions and Android Apps

Guys,

We've added a Google Conversation Web Element 
(http://www.google.com/webelements/social/conversation/)  for each app at 
AndAppStore using the title of the app followed by a space and "[Android 
Application]" (e.g. the AndAppStore Client discussion URL is 
http://www.google.com/friendconnect/discuss?scope=web&topic=AndAppStore+Client+%5BAndroid+Application%5D)
 , they're global conversations so app authors, app review sites, or anyone 
else can add them into their own page using the same Topic URL if they want to. 

At the moment they're only on the desktop web interface to AndAppStore because 
the Google implementation doesn't work well with the android browser (constant 
refreshes, nothing shown in the conversation box, etc.), but hopefully someone 
will think about that at some point and we'll add it in to the android browser 
interface as well.

Enjoy...

Al.

-- 

* Written an Android App? - List it at http://andappstore.com/ *

======
Funky Android Limited is registered in England & Wales with the
company number 6741909. The registered head office is Kemp House,
152-160 City Road, London, EC1V 2NX, UK.

The views expressed in this email are those of the author and not
necessarily those of Funky Android Limited, it's associates, or it's
subsidiaries.



--~--~---------~--~----~------------~-------~--~----~

2. Deleting buffer cache for IO throughput

Hi,

We are writing an application to measure throughput speed of SD card
on ARM-based Android target using Java APIs.

When we execute the application twice for read operation, results are
seen to be affected with buffer cache.

For example, first read throughput is 275 KBps and second read
throughput is 350KBps.

Application is simple Java-based application, it is .jar app. It is
not using the Application class  and hence, not having
AndroidManifest.xml present. ().

Is there any way to clear the buffer cache after each run of the
application ?

Thanks and Regards,
Vrukesh
--~--~---------~--~----~------------~-------~--~----~

3. Can't keep AlertDialog on screen when KeyEvent.KEYCODE_BACK is handled with 1.5 (??)

4. how to have onItemClickListener for setListAdapter(new EfficientAdapter(this));?

5. How to create a simple list of names, with personal image for each row

6. socket (server and client)_

7. Does the android 1.5 browser support navigator.geolocation?