0

I'm developing and android application in which I have created a ListActivity which contains an ImageView and a TextView. There is also the ability to drag and drop those objects so that they can be moved. What I want to do now is to have a button at the bottom of the screen,not the list.

As the user scrolls the button will always stay there. I found this link but when i did what this link suggested no button did appear, and instead i got a huge blank space that takes over a quarter of the screen. Can anyone point me to the right direction?

ok so here is the .xml file that is set to the ListActivity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
<DragNDrop.DragNDropListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  </DragNDrop.DragNDropListView>
</LinearLayout>

hopefully it can help

Community
  • 1
  • 1
Libathos
  • 3,340
  • 5
  • 36
  • 61

2 Answers2

4

Your view should be like this:

<?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="fill_parent" >
<Button 
     android:id="@+id/btn"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:text="Button"
     android:layout_centerHorizontal="true"/>
 <ListView 
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:layout_above="@+id/btn"/>
</RelativeLayout>

Populate the listview with the data and see the button will be on its place though list being scrolled.

AkashG
  • 7,868
  • 3
  • 28
  • 43
  • Ok I've done this as i said also in my question.My problem though stands still.Now I have a button on the top left part of the screen and all the data are shown only in the first row of the list leaving the whole screen blank.Do you think it would be better if I'd post the xml file that is associated with my ListActivity? – Libathos Jul 26 '12 at 11:59
  • yeah..you better post your code which would be easy for anyone to understand and solve your problem. – AkashG Jul 26 '12 at 12:00
  • ok you were right all along i was making a mistake the whole time using linearLyaout i payed more attenion and it worked thx a lot! – Libathos Jul 26 '12 at 12:30
  • Well i still have 2 additional problems.Firstly the button is unclickable.And secondly when the list is overlapsing it it seems see-through is there any way that it won't be transparent and the last field of the list won't be displayed? – Libathos Jul 26 '12 at 12:38
0

I think that ListActivity is a bad practice. What you need to do is to is to change the Activity from ListActivity to Activity. In the layout file, do the following:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_contant"
    android:orientation="horizontal">
 <DragNDrop.DragNDropListView
   android:id="@+id/android:list"
   android:layout_width="fill_parent"
   android:layout_height="wrap_contant">
 </DragNDrop.DragNDropListView>
 <Button 
    android:id="@+id/btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"/>
</LinearLayout>

In on create you can get the list reference by doing:

ListView lv = (ListView)findViewById(R.id.list); 

In order to make the button clickable, user OnClickListener

Uriel Frankel
  • 14,304
  • 8
  • 47
  • 69