我想加粗每一行的第一个字.而不是大胆它显示整个代码!
private voID addAsimA(ArrayList<String> products) { products.add("<b>Apple</b> It is red"); products.add("<b>Banana</b> It is yellow"); products.add("<b>Mango</b> It is green");
我怎样才能得到这样的输出:
Apple它是红色的
香蕉它是黄色的
芒果它是绿色的
这是完整的java文件
public class MainActivity extends Activity { TextVIEw txtv, txt1; ImageVIEw imgv; // List vIEw private ListVIEw lv; // ListvIEw Adapter ArrayAdapter<String> adapter; // ArrayList for ListvIEw ArrayList<HashMap<String, String>> productList; ArrayList<String> products = new ArrayList<String>(); /** Called when the activity is first created. */ @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); addAsimA(products); addAsimB(products); } private voID addAsimA(ArrayList<String> products) { products.add("<b>Apple</b> It is red"); products.add("<b>Banana</b> It is yellow"); products.add("<b>Mango</b> It is green"); } private voID addAsimB(ArrayList<String> products) { products.add("<b>Flower</b> It is nice"); products.add("<b>Fog</b> It is white"); products.add("<b>Rose</b> It is pink"); lv = (ListVIEw) findVIEwByID(R.ID.List_vIEw); // your code is added here but what is the problem? TextVIEw txt1 = (TextVIEw) findVIEwByID(R.ID.product_List); txt1.setText(HTML.fromHTML(products.get(productList))); // Adding items to ListvIEw adapter = new ArrayAdapter<String>(this, R.layout.List_item, R.ID.product_List, products); lv.setAdapter(adapter); } }
文本视图的XML文件位于:
<?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" > <!-- Product name --> <com.examdple.customproduct.CustomTextVIEw androID:textcolor="?androID:textcolorPrimary" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:paddingtop="4sp" androID:ID="@+ID/product_List" androID:paddingleft="20sp" androID:paddingBottom="2sp" androID:textSize="15sp" /></linearLayout>
如果有人想要文件:http://www.mediafire.com/?op37c1itodd8724
解决方法:
像这样:
TextVIEw txt = (TextVIEw) findVIEwByID(R.ID.myTxtV);txt.setText(HTML.fromHTML(products.get(index)));
总结 以上是内存溢出为你收集整理的android中部分粗体字符串全部内容,希望文章能够帮你解决android中部分粗体字符串所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)