Note that there are some explanatory texts on larger screens.

plurals
  1. POnot changing imageView image in a custom layout
    primarykey
    data
    text
    <p>i have a layout with a text an an image, every time i create a copy of this layout and adding to a parent layout, my problem in here that only first time of running loop imageView changed and other times this is not happened even with same image file!! im very confused !</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); fullPath = Environment.getExternalStorageDirectory().toString() + "/books/"; addFewBooks(); updateShelf(); } private void addFewBooks() { books.add(new BookItem(fullPath + "book1.epub", "book1", "cover1.jpg")); books.add(new BookItem(fullPath + "book2.epub", "book2", "cover1.jpg")); books.add(new BookItem(fullPath + "book3.epub", "book2", "cover2.jpg")); } public void LaunchBookViewActivity(String bookPath) { Intent intent = new Intent(MainActivity.this, BookViewActivity.class); intent.putExtra("bookPath", bookPath); startActivity(intent); } private List&lt;BookItem&gt; books = new ArrayList&lt;BookItem&gt;(); private void updateShelf() { LinearLayout parentPanel = (LinearLayout) findViewById(R.id.main_ll); parentPanel.removeAllViews(); LayoutInflater inflator = LayoutInflater.from(getBaseContext()); for (int i = 0; i &lt; books.size(); i++) { View item = (View) inflator.inflate(R.layout.book_item, null); try { ImageView coverIv = (ImageView) findViewById(R.id.book_item_img); coverIv.setImageDrawable(new BitmapDrawable( BitmapFactory.decodeFile((fullPath + books.get(i) .getCover())))); Log.d("SHF", books.get(i).getCover()); } catch (Exception e) { } TextView title = (TextView) item.findViewById(R.id.book_item_txt); title.setText(books.get(i).getTitle()); PersianReshape.setTextViewFace(title); parentPanel.addView(item); item.setOnClickListener(itemOnClick); books.get(i).setId(i); item.setTag(String.valueOf(i)); } } </code></pre> <p>book_item.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_rl" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:ignore="ContentDescription" &gt; &lt;ImageView android:id="@+id/book_item_img" android:layout_width="70dip" android:layout_height="100dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:src="@drawable/shelf_row1" android:scaleType="fitXY" /&gt; &lt;TextView android:id="@+id/book_item_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/book_item_img" android:layout_centerHorizontal="true" android:textColor="#ff000000" android:textSize="15dip" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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