android - seekbar not updating textview in Dialog custom layout -
i have layout seekbar , textview using inside dialog. when try update textview seekbar nothing happens.
i doing changes in onprogresschanged. here code milage_main.class:
public class milage_spinner extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); seekbar seekbar = (seekbar)findviewbyid(r.id.seekbar); seekbar.setprogress(10); seekbar.setmax(10); final textview sbv = (textview) findviewbyid(r.id.drivetime); final edittext drive_time = (edittext)findviewbyid(r.id.runtime); seekbar.setonseekbarchangelistener(new seekbar.onseekbarchangelistener(){ @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { sbv.settext(string.valueof(progress)); drive_time.settext(progress); } @override public void onstarttrackingtouch(seekbar seekbar) { } @override public void onstoptrackingtouch(seekbar seekbar) { } }); } }
and here dialog builder in mainactiviy.class getting layout milage_seekbar
private dialog createmilage(){ alertdialog.builder builder = new alertdialog.builder(this); layoutinflater inflater = this.getlayoutinflater(); linearlayout linearlayout = (linearlayout)inflater.inflate(r.layout.milage_spinner,null); builder.setview(linearlayout) .settitle("ktd") .setnegativebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int i) { dialog.dismiss(); } }) ; return builder.create(); }
and xml in layout milage_seekbar looks this:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="1"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="large text" android:id="@+id/drivetime" android:layout_gravity="center_horizontal" /> <seekbar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/seekbar" android:layout_gravity="center_horizontal" /> </linearlayout>
is possible make onprogresschanged inside dialog in mainactivity?
milage_spinner xml code
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:padding="2dp" android:layout_gravity="center" > <textview android:id="@+id/set_size_help_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="please select snowflake size" android:textsize="25dp" /> <seekbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/size_seekbar" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_margintop="10dp" /> </linearlayout>
change dialog alertdialog in java code , call oncreate.
private alertdialog createmilage() { layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view layout = inflater.inflate(r.layout.milage_spinner, (viewgroup) findviewbyid(r.id.layout)); alertdialog.builder builder = new alertdialog.builder(this) .setview(layout); builder.setpositivebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { dialog.dismiss(); } }); alertdialog alertdialog = builder.create(); alertdialog.show(); seekbar sb = (seekbar) layout.findviewbyid(r.id.size_seekbar); final textview set_size_help_text = (textview) layout.findviewbyid(r.id.set_size_help_text); sb.setonseekbarchangelistener(new seekbar.onseekbarchangelistener() { @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { set_size_help_text.settext("" + progress); } @override public void onstarttrackingtouch(seekbar seekbar) { } @override public void onstoptrackingtouch(seekbar seekbar) { } }); return alertdialog; }
Comments
Post a Comment