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. how to update the firmware of the dev phone to 1.1?

That will not get you 1.1 - it will get you master, which (iirc) is to be
called 1.5. (What it is right now is a bleeding edge development branch,
that is rarely updated from the internal google branches, plus the fixes
needed to build without google's huge collection of closed-source apps and
framework pieces.)

On master wifi, etc works fine. It is just google apps that are missing.
(For the interested, I host fastbootable-images at
http://andblogs.net/images/snapshots - I update them every day or two, as
changes are pushed into the public tree.)

For 1.1, your official options are "sucks to be you". Your unofficial
options are a little better - since google updated all their employees
phones you can install the 'holiday' update. (Available for any
testkeys-enabled phone - like the adp1 - at http://is.gd/j2uK .. use the
'nochecks' version.) Google updated their employees phones instead of the
adp1 phones, probably to make sure you knew your place.. :(









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

2. Is the developer or Android Market selling the Apps?

If I had to guess, given that it's apparently impossible to buy an app from
the Android Market in any other currency than dollars, that collecting and
documenting VAT is another aspect of all of this that hasn't actually been
thought through. And no, history would suggest that you won't get anything
like authoritative advice here. Which is interesting, all by itself.

(This may not get posted to the android-discuss list--last I heard, I was
still being "moderated" by Dan Morrill for having actually attempted to
discuss a news story here...)






-- 


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

3. BroadcastReceiver for a Service to catch broadcast Intent ACTION_BOOT_COMPLETED

4. poblem in reading file of android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI

5. crash in com.android.camera after calling Images.Media.insertImage

6. Emualator fails at Boot up

7. Developing an IMS client on Android : Request for Comments.