问题
Edit: I removed my exception information. With the Help of @Sam I was able to use fix project properties and the application no longer force closes on me. Though, rearranging the layout from image textview to textview image causes it to not display images. Does anyone have any idea why? All code can be found here http://www.ezzylearning.com/tutorial.aspx?tid=1763429
I am attempting to follow this tutorial http://www.ezzylearning.com/tutorial.aspx?tid=1763429 I have everything working as posted. I am adopting this for a more complex layout. I tried to change something very simple. I moved the image from the left to the right.
BEFORE
<ImageView android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="22dp"
android:textColor="#000000"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
AFTER
<TextView android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="22dp"
android:textColor="#000000"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<ImageView android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
回答1:
This makes no sense!
- Try cleaning your project: Project -> Clean...
- Or use Fix Properties from Android Tools
Also your ImageView and TextView are sitting on top of each other, you might want to add android:layout_width="wrap_content"
and android:layout_weight="5"
to the TextView and android:layout_weight="1"
to the ImageView. ... :)
回答2:
I had similar issue, although with different components.
What worked for me, not sure why is rearranging the xml file. placing the ImageView
before the TextView
Meaning,
<ImageView android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="22dp"
android:textColor="#000000"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
回答3:
You should not do
row = inflater.inflate(layoutResourceId, parent, false);
but
row = inflater.inflate(layoutResourceId, null, false);
That may be be cause. I already got exceptions due that.
来源:https://stackoverflow.com/questions/13336037/custom-list-adapter-wont-display-pictures