0

i'm trying to develop the given UI in android, there is a ListView and on top of it a button is visible , listView's height is Fill_PARENT and button is fix at it's position.

How to add a view above of a view? or any idea about creating this layout using XML or customizedView.

enter image description here

Houcine
  • 24,001
  • 13
  • 56
  • 83
strike
  • 1,031
  • 8
  • 24

2 Answers2

1

you need to create your layout for your item , and ovverride the BaseAdapter to create your own adapter for your custom ListView ,

see this tutorial to learn how to create a custom ListView

see this question it is similar to your case : how to customize listview row android

and finally , this tutorial is very good and it manage the selection states for your list items :

Community
  • 1
  • 1
Houcine
  • 24,001
  • 13
  • 56
  • 83
  • my question is not related with ListView adapter, i have to display the Button above the listView.it's like adding a view in the subView of another view in iOS. – strike Jun 20 '12 at 11:15
  • you want to have a button above your listView ??? so add it in your xml layout , i didn't understand what you really want :) – Houcine Jun 20 '12 at 11:32
  • yes the button should be above the listView.how's it is possible using xml layout or runtimeView. – strike Jun 20 '12 at 11:37
  • i don't know if you want that your button should be visible all the time above your listView, so you don't need to add it on runtime , simply add it on the layout xml , by using a RelativeLayout , and place your ListView bellow the button :) – Houcine Jun 20 '12 at 11:39
0

I think from what i understand in your question it seems like you are looking for FrameLayout. So there is a list view and top of it is a button. Right? Try this.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/mainlayout" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">

<ListView android:layout_height="fill_parent" android:layout_width="fill_parent" android:padding="10dp" android:id="@+id/myListView"/>

<ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/buttondrawable" />
</FrameLayout>
Wesley
  • 1,808
  • 5
  • 31
  • 46
  • thanks for the clue i'm using FrameLayout as an parent it might seems to be working. – strike Jun 22 '12 at 10:24
  • by the way by any chance, are you doing something similar to (Path App) like button? - Just out of my curiosity! – Wesley Jun 22 '12 at 10:48
  • @Wesley : do you have any idea or code about how to do like the button Add at the bottom of the Path App ?? – Houcine Jun 22 '12 at 13:46
  • @Wesley : if you want more perfect solutions for that button of path app ; see this thread ;) http://stackoverflow.com/questions/9922127/how-to-create-animation-like-path-application-in-android , enjoy ;) – Houcine Jun 22 '12 at 14:50
  • Thanks, I've seen those too :) – Wesley Jun 22 '12 at 15:22