0
我在導航抽屜內有一個Expandable列表視圖。可擴展listView是我想要顯示在導航抽屜下方的imageView中的不同圖像的列表。我測試了應用程序,並在結果中獲得了一些圖像,其他沒有。這可能是什麼原因?ImageView未顯示圖像
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(this, (CharSequence) v.getTag(),
Toast.LENGTH_SHORT).show();
//Drawer closes
drawerList.setItemChecked(childPosition, true);
mDrawerLayout.closeDrawer(drawerList);
ImageView iv = (ImageView) findViewById(R.id.test);
ArrayList<String> myList = childItem.get(groupPosition);
//Algebra
if(myList.get(childPosition).equals("Quadratic equations")){
iv.setImageResource(R.drawable.a_a);
}else if(myList.get(childPosition).equals("Special Products")){
iv.setImageResource(R.drawable.a_b);
}else if(myList.get(childPosition).equals("Power Laws")){
iv.setImageResource(R.drawable.a_d);
}else if(myList.get(childPosition).equals("Arithmetic")){
iv.setImageResource(R.drawable.a_e);
}
xml文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:background="#FFFFFF"
android:orientation="vertical"
android:tileMode="repeat"
android:scaleType="fitXY" >
<ImageView
android:id="@+id/test"
android:layout_width="wrap_content"
android:src="@drawable/splash_formulas"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:background="#FFFFFF"
android:orientation="vertical"
android:scaleType="fitXY" />
</ScrollView>
</FrameLayout>
<!-- The navigation drawer -->
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/background"
android:choiceMode="singleChoice"
android:divider="#c6c6c6"
android:dividerHeight="1px"
android:groupIndicator="@android:color/white" />
</android.support.v4.widget.DrawerLayout>
你什麼時候使用例如調試你得到正確的輸出Log.w(「App」,「String:」+ myList.get(childPosition))? – Boni2k