Question

i have a problem which keeps me for two weeks. please consider that i am not an android expert programmer. so i depend on your help.

the mainactivity in my application extends an ActionBarActivity. in my case, i want to display two different views (e.g. view A and view B) for the user. With the SectionsPagerAdapter its possible to swipe between them. The view A has two buttons "add" and "show". By clicking the "add" button, its possible to add a person. to do this, its necessary to enter a name and an amount. also it is possible but not necessary to capture and save a photo with the camera, if i want to add a person. the photo is stored on the sd card. the informations about an added person is stored in a sqlite database. if i added a person with a photo, then i stored also the path of the photo as a string in the database. the "show" button opens another activity to display the stored information about the added persons from the database in a custom listview.

the row of my listview has two textviews (for the name and amount) and an imageview. up to this point everything is ok. i can load the imformation by using a simplecursoradapter

cursor = myDBHandler.getAllPersons();   

//n= name, a=amount, p=picture
    final String[] from = new String[] {"n", "a", "p"};

    int[] to = new int[] {R.id.txt_name,
                          R.id.amount,
                          R.id.list_userImage};

    simpleCursorAdapter = new SimpleCursorAdapter(this, R.layout.mainlist_listrow, cursor, from, to);
 mainList.setAdapter(simpleCursorAdapter);

my problem is to load or to get the saved photos as an thumbnail image for the listview. The stored photos are too big (2448x3264 pixels). my imageview has a size of 50x50dip.

i found this tutorial. i think, that would help me possibly but i am not sure how to use the methods there in my case. i dont want to display all the pictures on my sd card, only the photos, which paths is stored in the database. how i said, i am not an expert programmer. i am not understanding the code lines in the tutorial and i am very confused. I'm not even sure if that works at all. certainly everyone know in the android the contact list. the contacts can displayed with a thumbnail image, even if the photo is very large. i want the same function. please help me with this.

No correct solution

OTHER TIPS

can you implement something like this to your image view: (it should automatically fit the image to that size within the view)

image_view.requestLayout();
image_view.getLayoutParams().height = 50;
image_view.getLayoutParams().width = 50;

found this here. However I found in my situation it was easier to just make each image the size I wanted. There was then no memory overload from resizing each image.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top