java - Android I Need 1 Superscript Character in the MIDDLE of a String in the Middle of an Array -
now saw tons of options none of them work me or far indirect me sort of uh, extrapolate need.
what have list view , there's few places need use superscript 6, cannot life of me find way in data list array...
the main java behind activity:
cadence_list cadence_list_data[] = new cadence_list[] { new cadence_list("perfect authentic", "v→i", "v→i", "strongest", "must been in root position tonic doubled in soprano", "definitive end of section/piece"), new cadence_list("imperfect authentic", "v→i", "v→i", "extremely strong", "v tonic 1 or more inverted or not containing tonic in soprano; v7, vii° , vii°⁶ subsitute v", "firm end of section/piece"), new cadence_list("half", "any→v", "any→v", "weak", "---", "creates desire continue on"), new cadence_list("phrygian half", "---", "vi⁶→v", "weak", "v7 can substitute v", "creates desire continue, particularly faster section"), new cadence_list("lydian half", "---", "iv⁶→v", "weak", "entire iv⁶ chord raised ½ step", "exactly phryigian half, more discordant beginning"), new cadence_list("plagal", "iv→i or ii⁶→i", "iv→i", "weak", "usually preceeded or followed stronger cadence", "reverential sound requiring absolution or following stronger cadence"), new cadence_list("deceptive", "v→not i", "v→not i", "moderate", "cannot go in major or in minor", "generates feeling resolution denies resolution, causing unease") }; cad_listadapter adapter = new cad_listadapter(this, r.layout.cad_list_layout, cadence_list_data); cad_list = (listview)findviewbyid(r.id.cad_list); view header = (view)getlayoutinflater().inflate(r.layout.cad_list_head, null); cad_list.addheaderview(header); cad_list.setadapter(adapter);
the custom constructor (cadence_list):
public class cadence_list { public string cad_name; public string maj_prog; public string min_prog; public string strength; public string restrict; public string feel; public cadence_list() { super(); } public cadence_list(string cad_name, string maj_prog, string min_prog, string strength, string restrict, string feel) { super(); this.cad_name = cad_name; this.maj_prog = maj_prog; this.min_prog = min_prog; this.strength = strength; this.restrict = restrict; this.feel = feel; } }
the custom adapter (cad_listadapter):
public class cad_listadapter extends arrayadapter<cadence_list> { context context; int layoutresourceid; cadence_list data[] = null; public cad_listadapter(context context, int layoutresourceid, cadence_list[] data) { super(context, layoutresourceid, data); this.layoutresourceid = layoutresourceid; this.context = context; this.data = data; } @override public view getview(int position, view convertview, viewgroup parent) { view row = convertview; cad_listholder holder = null; if (row == null) { layoutinflater inflater = ((activity)context).getlayoutinflater(); row = inflater.inflate(layoutresourceid, parent, false); holder = new cad_listholder(); holder.txttitle1 = (textview)row.findviewbyid(r.id.cad_name); holder.txttitle2 = (textview)row.findviewbyid(r.id.maj_prog); holder.txttitle3 = (textview)row.findviewbyid(r.id.min_prog); holder.txttitle4 = (textview)row.findviewbyid(r.id.restrict); holder.txttitle5 = (textview)row.findviewbyid(r.id.strength); holder.txttitle6 = (textview)row.findviewbyid(r.id.feel); row.settag(holder); } else { holder = (cad_listholder)row.gettag(); } cadence_list cadence_list = data[position]; holder.txttitle1.setvisibility(view.visible); holder.txttitle2.setvisibility(view.visible); holder.txttitle3.setvisibility(view.visible); holder.txttitle4.setvisibility(view.visible); holder.txttitle5.setvisibility(view.visible); holder.txttitle6.setvisibility(view.visible); holder.txttitle1.settext(cadence_list.cad_name); holder.txttitle2.settext(cadence_list.maj_prog); holder.txttitle3.settext(cadence_list.min_prog); holder.txttitle4.settext(cadence_list.restrict); holder.txttitle5.settext(cadence_list.strength); holder.txttitle6.settext(cadence_list.feel); return row; } class cad_listholder { textview txttitle1; textview txttitle2; textview txttitle3; textview txttitle4; textview txttitle5; textview txttitle6; } }
so can see there, , that's inside of data array. how can work?
i using html link here. superscript html tags <sup></sup>
tags used introduce superscript notation "6" (simplest) regular exp used replace instances of 6
6. sure can come better , more powerful regexes control output.
this code should try:
@override public view getview(int position, view convertview, viewgroup parent) { view row = convertview; cad_listholder holder = null; if (row == null) { layoutinflater inflater = ((activity)context).getlayoutinflater(); row = inflater.inflate(layoutresourceid, parent, false); holder = new cad_listholder(); holder.txttitle1 = (textview)row.findviewbyid(r.id.cad_name); holder.txttitle2 = (textview)row.findviewbyid(r.id.maj_prog); holder.txttitle3 = (textview)row.findviewbyid(r.id.min_prog); holder.txttitle4 = (textview)row.findviewbyid(r.id.restrict); holder.txttitle5 = (textview)row.findviewbyid(r.id.strength); holder.txttitle6 = (textview)row.findviewbyid(r.id.feel); row.settag(holder); } else { holder = (cad_listholder)row.gettag(); } cadence_list cadence_list = data[position]; holder.txttitle1.setvisibility(view.visible); holder.txttitle2.setvisibility(view.visible); holder.txttitle3.setvisibility(view.visible); holder.txttitle4.setvisibility(view.visible); holder.txttitle5.setvisibility(view.visible); holder.txttitle6.setvisibility(view.visible); holder.txttitle1.settext(html.fromhtml(cadence_list.cad_name.replaceall("6", "<sup>6</sup>"))); holder.txttitle2.settext(html.fromhtml(cadence_list.maj_prog.replaceall("6", "<sup>6</sup>"))); holder.txttitle3.settext(html.fromhtml(cadence_list.min_prog.replaceall("6", "<sup>6</sup>"))); holder.txttitle4.settext(html.fromhtml(cadence_list.restrict.replaceall("6", "<sup>6</sup>"))); holder.txttitle5.settext(html.fromhtml(cadence_list.strength.replaceall("6", "<sup>6</sup>"))); holder.txttitle6.settext(html.fromhtml(cadence_list.feel.replaceall("6", "<sup>6</sup>"))); return row; }
Comments
Post a Comment