Android: Implementing Slideshow -
i trying implement slideshow in android app. have imageview , text view in xml file. want imageview show slideshow of images. images stored in drawable-hdpi. when opening page, text view showing , not slideshow. not single image showing. following java file same.
package abc.xys; import android.annotation.suppresslint; import android.app.activity; import android.os.bundle; import android.os.handler; import android.os.message; import android.widget.imageview; import android.widget.textview; public class wishes extends activity { imageview slide; textview msg; int i=0; int imgid[]={r.drawable.friends01,r.drawable.friends02,r.drawable.friends03,r.drawable.friends04,r.drawable.friends05}; refreshhandler refreshhandler=new refreshhandler(); @suppresslint("handlerleak") class refreshhandler extends handler{ @override public void handlemessage(message msg) { // todo auto-generated method stub wishes.this.updateui(); } public void sleep(long delaymillis){ this.removemessages(0); sendmessagedelayed(obtainmessage(0), delaymillis); } }; public void updateui(){ int currentint=integer.parseint((string)msg.gettext())+10; if(currentint<=100){ refreshhandler.sleep(2000); msg.settext(string.valueof(currentint)); if(i<imgid.length){ slide.setimageresource(imgid[i]); // slide.setpadding(left, top, right, bottom); i++; } } } @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.wishes_template); slide = (imageview) findviewbyid(r.id.slideshow); msg = (textview) findviewbyid(r.id.message); } }
the xml file (wishes_template) is:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/slideshow_layout" > <imageview android:id="@+id/slideshow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingtop="20dp" ></imageview> <textview android:text="10" android:id="@+id/message" android:layout_width="fill_parent" android:layout_height="wrap_content"></textview> </linearlayout>
thanks in advance!
Comments
Post a Comment