开发者

listview footer dynamically change state android

I have ListView and I want add footer. I easily did it through standard addFooterView method. But footer added into end of ListView and displayed as part of ListView开发者_如何学运维 (i.e. if ListView items more then placed on the screen then footer outside the screen).

Why I need it: I want show button when user interacted with some View in ListView. And "lift up" ListView border at bottom of screen on (current height value - height value of button).

The problem is: onClickListener required View in adapter. And setContentView in Activity. I do not get access to the parameters of a button from the adapter to ListActivity.

My XML Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ListView 
android:id="@+id/watchAddList"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:scrollbars="none"
android:listSelector="@drawable/list_selector"
    style="@style/listViewStyle">
</ListView>

 <include 
  layout="@layout/submit" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" />  
 </RelativeLayout>

And include Layout:

<?xml version="1.0" encoding="UTF-8"?>
  <RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:id="@+id/rl_submit">

<Button 
android:id="@+id/submit"    
android:layout_height="wrap_content"
 android:text="Сохранить" 
android:layout_width="fill_parent" 
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true"></Button>
</RelativeLayout>

UPD: I do It! i used Singleton, and call Activity instance in Adapter class, then got access to the button properties. Cool!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜