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. Database location and management via external tools.

How can I get direct access to created database (via sqlite tools)?
I'm develop application that should contain an already formed and
filled database. Also, I want manage this database via external tools
(mySql for example) and provide only fulfilled database within
completed application.

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

2. Native MediaPlayer plays audio but not video (3gp format)

Hi,
I have the following native source code that is supposed to display
video.
It plays 3gp file ok and I can hear the audio, but the video is not
shown.

Code:

// Global surface initialized elsewhere
extern sp<Surface> g_surface;

void media_player_test(void) {
    MediaPlayer *mp;

    mp = new MediaPlayer();
    if(mp == NULL) {
        return;
    }

    mp->setDataSource("/data/local/video.3gp");
    mp->setVideoSurface(g_surface);
    mp->prepare();
    mp->start();
}

End of code

In Java I manage to play video with almost the same implementation.
The only difference I can see is that Java code calls setType() for
the surface holder.
I can't find a matching operation for setType() in native code.
Is it important?

One more thing, I tried with and without listeners/callbacks, but the
video still doesn't play.

Thank you.
David

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

3. Transparency on Views behaving differently in 1.5

4. Make a application default launcher

5. How can disable/suspend/resume audio service at runtime?

6. How to debug on an actual device?

7. android market merchant accounts not available in europe