Android edit text showing weird text -
i new android. created simple application using aynctask. basically, uses asynctask iterate through loop , show iteration number in text box. created both edittext , textview , bot shows weird text. try creating toast, , toast shows same text correctly. here source code:
package com.jeannius.me; import android.app.activity; import android.os.asynctask; import android.os.bundle; import android.os.systemclock; import android.text.inputtype; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class main extends activity { /** called when activity first created. */ int[] color1 = {0xffe48701, 0xffa5bc4e, 0xff1b95d9, 0xffcaca9e, 0xff6693b0, 0xfff05e27, 0xff86d1e4, 0xffe4f9a0, 0xffffd512, 0xff75b000, 0xff0662b0, 0xffede8c6, 0xffcc3300, 0xffd1dfe7, 0xff52d4ca, 0xffc5e05d, 0xffe7c174, 0xfffff797, 0xffc5f68f, 0xffbdf1e6, 0xff9e987d, 0xffeb988d, 0xff91c9e5, 0xff93dc4a, 0xffffb900, 0xff9ebbcd, 0xff009797, 0xff0db2c2}; textview yyr; edittext ud; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); yyr = (textview)findviewbyid(r.id.mytext); ud = (edittext)findviewbyid(r.id.edit); button myb =(button)findviewbyid(r.id.mybut); yyr.settextcolor(0xffe48701); ud.setrawinputtype(inputtype.type_class_text); myb.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { new mysynctask().execute(); } }); } class mysynctask extends asynctask< void, integer, void>{ string red; @override protected void doinbackground(void... unused) { for(integer j=0; j<5; j++){ red = string.valueof(j); publishprogress(j); systemclock.sleep(3000);} return null; } @override protected void onpostexecute(void result) { toast.maketext(getapplicationcontext(), red.tostring(), toast.length_long).show(); } protected void onprogressupdate(integer... values) { yyr.settext(string.valueof(values)); ud.settext(values.tostring(), textview.buffertype.editable); toast.maketext(getapplicationcontext(), red.tostring(), toast.length_short).show(); } } }
values array. use this: string.valueof( values[0] )
Comments
Post a Comment