0

I am trying to add a small home icon image to top of my list view.Below you can see the code of my adapter. It works perfectly for setting dynamic text but it fails when i want to add an image.

I do not get any runtime error, just the images aren't loaded.

The images referenced are 35x35 png file.

How to implement this? Im new to android. please guide me.

      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      viewList = Nexttopic.this.getLayoutInflater().inflate(R.layout.activity_nexttopic, null);
      dialogMarketList = new Dialog(Nexttopic.this);
      dialogMarketList.requestWindowFeature(Window.FEATURE_NO_TITLE);
      dialogMarketList.setContentView(viewList);
      dialogMarketList.show();     
      lvForDialog = (ListView) viewList.findViewById(R.id.List_view);
      lvForDialog.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
      ArrayAdapter<String> adapter = (new ArrayAdapter<String>(Nexttopic.this, R.layout.row_topic, R.id.child_row,tnamelist));
      ImageView home = (ImageView) findViewById(R.id.hme);
      lvForDialog.setAdapter(adapter); 

row_topic xml file

       <?xml version="1.0" encoding="utf-8"?>  
       <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" 
           android:weightSum="1">
         <ImageView      android:id="@+id/hme"  
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" 
            android:layout_above="@+id/child_row"
            android:src="@drawable/homex"/>
          <TextView 
            android:id="@+id/child_row"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:gravity="center_vertical"
            android:paddingLeft="6dip"
            android:minHeight="?android:attr/listPreferredItemHeight"
            android:background="@drawable/bg"/>
            </RelativeLayout>

activity_nexttopic

              <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:android1="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Nexttopic" >

        <ListView
        android1:id="@+id/List_view"
        android1:layout_width="match_parent"
        android1:layout_height="250dp"
        android1:layout_centerHorizontal="true"
        android1:layout_centerVertical="true"
        android:background="@drawable/bg">
        </ListView>
        </RelativeLayout>
Make it Simple
  • 1,832
  • 5
  • 32
  • 57

0 Answers0