android - format a string with fill places -
i have setup edittext box , set maxlength 10. when copy edittext string mytitles. need mytiles 10 chars long , not dependent on entered in edittext box.
mytitles[0] = titlesedit.gettext().tostring();
the edittext filled abcd need add 6 spaces or placeholders after abcd. have seen other post str_pad , substr without success
mytitles[0] = str_pad(strtest, 0, 10); mytitles[0] = substr(strtest,0, 10);
try like
public static string newstring(string str) { (int = str.length(); <= 10; i++) str += "*"; return str; }
this return string *
replaced empty ones.
so, eg, if string abcde
, on calling newstring()
below
mytitles[0] = newstring("abcde");
will return abcde*****
output.
Comments
Post a Comment