Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - adding photos taken by the user into a listview
    primarykey
    data
    text
    <p>I currently have a simple list view adapter that holds two rows of text. What I am trying to do next is add the option of displaying a photo that the user took in the list view. I modified my list adapter like so: </p> <pre><code>standardAdapter = new SimpleAdapter(this, list, R.layout.post_layout, new String[] { "time", "post", "image"}, new int[] { R.id.postTimeTextView, R.id.postTextView, R.id.post_imageView}); </code></pre> <p>Then I add it to the hash map as usual and refresh the adapter:</p> <pre><code>// create a new hash map with the text from the post feedPostMap = new HashMap&lt;String, Object&gt;(); feedPostMap.put("time", currentTimePost); feedPostMap.put("post", post); if(photoWasTaken == 1){ feedPostMap.put("image", pictureTaken); } //add map to list list.add(feedPostMap); // refresh the adapter standardAdapter.notifyDataSetChanged(); </code></pre> <p>Lastly, here is the code for activity on result:</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d(TAG, "ON activity for result- CAMERA"); if (resultCode == Activity.RESULT_OK) { //get and decode the file pictureTaken = BitmapFactory.decodeFile("/sdcard/livefeedrTemp.png"); //Display picture above the text box imageViewShowPictureTaken.setImageBitmap(pictureTaken); displayPhotoLayout.setVisibility(LinearLayout.VISIBLE); //NEW - make photo variable = 1 photoWasTaken = 1; } } </code></pre> <p>However I am running into an issue. The photo, in bitmap form, is not being added to the list view. It just appears as empty white space. Am I doing something wrong here? Secondly, if the user decided not to take a picture, then the image view should not be displayed. I'm not sure how to implement this. Should I create a custom list adapter? </p> <p>Thanks for your help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload