1

I am new in Android .I want to create a listview.By using images.

I want to put on the Header Logo of the Company on the top of the page . After that i want to repeat the list. My XML file Code is here please suggest me the update

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/list_selector"
    android:orientation="horizontal"
    android:padding="5dip" >

    <!--  ListRow Left sied Thumbnail image -->
    <LinearLayout android:id="@+id/thumbnail" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="3dip"      
        android:layout_alignParentLeft="true"
        android:background="@drawable/image_bg" 
        android:layout_marginRight="5dip">

        <ImageView     
            android:id="@+id/list_image"   
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:src="@drawable/ic_launcher"/>

    </LinearLayout>


    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/thumbnail"
        android:layout_toRightOf="@+id/thumbnail"
        android:text="Hotels"
        android:textColor="#040404"
        android:typeface="sans" 
        android:textSize="15dip"
        android:textStyle="bold"/>


    <TextView
        android:id="@+id/artist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title"
        android:textColor="#343434"
        android:textSize="10dip"
        android:layout_marginTop="1dip"
        android:layout_toRightOf="@+id/thumbnail"
        android:text="Hotel Text " />


     <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/arrow"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"/>

</RelativeLayout>

2 Answers2

0

Try following layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="5dip" >

    <!-- ListRow Left sied Thumbnail image -->

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="5dp"
        android:layout_marginRight="5dip"
        android:padding="3dip"
        android:src="@drawable/ic_launcher" />

    <!-- Repeat this layout number of times -->

    <RelativeLayout
        android:id="@+id/relative1"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_below="@+id/imgLogo"
        android:layout_marginTop="5dp"
        android:background="@android:color/darker_gray"
        android:gravity="center_vertical" >

        <ImageView
            android:id="@+id/list_image"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_alignParentLeft="true"
            android:layout_marginRight="5dip"
            android:padding="3dip"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/list_image"
            android:layout_marginRight="5dp"
            android:layout_marginTop="10dp"
            android:layout_toLeftOf="@+id/imgRight"
            android:layout_toRightOf="@+id/list_image"
            android:text="Hotels"
            android:textColor="#040404"
            android:textSize="15dip"
            android:textStyle="bold"
            android:typeface="sans" />

        <TextView
            android:id="@+id/artist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_marginRight="5dp"
            android:layout_toLeftOf="@+id/imgRight"
            android:layout_toRightOf="@+id/list_image"
            android:text="Hotel Text "
            android:textColor="#343434"
            android:textSize="10dip" />

        <ImageView
            android:id="@+id/imgRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_launcher" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/relative2"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_below="@+id/relative1"
        android:layout_marginTop="5dp"
        android:background="@android:color/darker_gray"
        android:gravity="center_vertical" >

        <ImageView
            android:id="@+id/list_image"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_alignParentLeft="true"
            android:layout_marginRight="5dip"
            android:padding="3dip"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/list_image"
            android:layout_marginRight="5dp"
            android:layout_marginTop="10dp"
            android:layout_toLeftOf="@+id/imgRight"
            android:layout_toRightOf="@+id/list_image"
            android:text="Hotels"
            android:textColor="#040404"
            android:textSize="15dip"
            android:textStyle="bold"
            android:typeface="sans" />

        <TextView
            android:id="@+id/artist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_marginRight="5dp"
            android:layout_toLeftOf="@+id/imgRight"
            android:layout_toRightOf="@+id/list_image"
            android:text="Hotel Text "
            android:textColor="#343434"
            android:textSize="10dip" />

        <ImageView
            android:id="@+id/imgRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_launcher" />
    </RelativeLayout>

</RelativeLayout>
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
  • Pleas refer this http://s15.postimg.org/43bstxvkb/Home.jpg.I want to place company logo at top den this part in repitions .It is fixed layout –  Jul 11 '13 at 06:37
  • have you implemented that layout? then you will get an idea that how to do that. You can implement in your own way. I given an idea to you. Rest of work is yours. – Chintan Rathod Jul 11 '13 at 06:40
  • Issue i am facing is how i can put the logo on the top .If u can suggest me i will be thankfull to u @chintan –  Jul 11 '13 at 06:47
  • @user2568702, Glad to help.. whenever you have sufficient reputation, please upvote. :) – Chintan Rathod Jul 11 '13 at 07:00
  • can u suggest some thing to me on this problem http://stackoverflow.com/questions/17593929/how-to-use-onhover-in-android –  Jul 11 '13 at 13:05
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/33344/discussion-between-rahul-and-chintan-rathod) –  Jul 12 '13 at 09:35
  • will u please help me on this http://stackoverflow.com/questions/17647523/how-to-create-a-lauyout-with-menu-and-autolookup-box-in-android –  Jul 15 '13 at 05:57
  • as per u r comments i have create my layout thanks u for the reference please see this http://stackoverflow.com/questions/17647523/how-to-create-a-form-that-have-autolookup-in-android... –  Jul 15 '13 at 09:48
0

Your xml code is right please inflate this layout in your adapter getView method and set listView.

nilesh patel
  • 834
  • 1
  • 5
  • 10