ImageView没有显示图像

时间:2014-06-17 12:17:17

标签: android listview

我在导航抽屉中有一个Expandable listView。可展开的listView是我想要在导航抽屉下面的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>

1 个答案:

答案 0 :(得分:0)

在ImageViews上缺少位置

 <ImageView  android:id="@+id/img11"
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_alignParentRight="true"
             android:src="@drawable/img1"
/>