Insert different images in each row of a list

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Insert different images in each row of a list

Postby kolch9 » Mon Jul 06, 2009 1:34 pm

Hi!!!i would like to put a different image for each row in a list depending from a value that i take from a database..can you help me please??it's very important for me!!!this is my code

private void fillData() {


// Get all of the rows from the database and create the item list
patientCursor = dbHelper.getAllEntriesPatient(orderList);
startManagingCursor(patientCursor);

// Create an array to specify the fields we want to display in the list (only TITLE)
String[] from = new String[]{Dbadapter.KEY_REGN,Dbadapter.KEY_NAME,
Dbadapter.KEY_SURNAME,Dbadapter.KEY_PRIORITY};

// and an array of the fields we want to bind those fields to
int[] to = new int[]{R.id.text2,R.id.text1,R.id.text3,R.id.text4};

// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, patientCursor, from, to);



// Integer a=new Integer(null);
// a=(Integer)notes.getItem(3);
/* Drawable d;
d = this.getResources().getDrawable(R.drawable.priority2);
switch (2) {
case 2:
d = this.getResources().getDrawable(R.drawable.priority2);
break;
case 3:
d = this.getResources().getDrawable(R.drawable.priority3);
break;
case 4:
d = this.getResources().getDrawable(R.drawable.priority4);
break;
case 5:
d = this.getResources().getDrawable(R.drawable.priority5);
break;
default:
d = this.getResources().getDrawable(R.drawable.priority1);
break;
}

ImageView img = (ImageView)findViewById(R.id.icon);
img.setImageDrawable(d);*/


setListAdapter(notes);

AnimationSet set = new AnimationSet(true);

Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);

animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(100);
set.addAnimation(animation);

LayoutAnimationController controller =
new LayoutAnimationController(set, 0.5f);
if (typeOrderReverse) controller.setOrder(LayoutAnimationController.ORDER_REVERSE);
ListView listView = getListView();
listView.setLayoutAnimation(controller);

}

any ideas??thanks!!!!!
kolch9
Junior Developer
Junior Developer
 
Posts: 11
Joined: Wed Feb 18, 2009 2:17 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests