Friday, April 22, 2011

Dynamically Loading Data's (Adding Footer to ListView ) in ListView in Android


Add a footer to List View and when the user clicks that Footer, you can show parse the next set of data and show it in the list.



Step1: Create a Button

<Button android:id="@+id/footer" android:gravity="center"
android:layout_gravity="center"
android:text="My Footer"
android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_weight="1"/>

Step2: Make it as Footer to the List View

ListView myList;
View footerView;
ViewGroup footerViewOriginal = (ViewGroup) findViewById(R.id.footer);
footerView = inflater2.inflate(R.layout.footer,footerViewOriginal);
footerView.findViewById(R.id.footer);
myList.addFooterView(footerView, null, true);

Step3: Create on ClickListener and write the action what you want to perform

footerView.findViewById(R.id.footer).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;

}

1 comment:

  1. I always spent my half an hour to read this blog's content daily along with a mug of coffee.
    my website - Recovering email from exchange offline folder office 2007

    ReplyDelete

Notification in Android Using AlarmManager, BoradCastReceiver & Services

    Our aim is to show notification message to user in a specific time.     Say For example , I have planned to show Notification ...