Partially bold string in android
<p>I want to bold the first word of each line. But rather then being bold it shows entire code!</p>

<pre><code> private void addAsimA(ArrayList&lt;String&gt; products) {
         products.add("&lt;b&gt;Apple&lt;/b&gt; It is red");
         products.add("&lt;b&gt;Banana&lt;/b&gt; It is yellow");
         products.add("&lt;b&gt;Mango&lt;/b&gt; It is green");
</code></pre>

<p>How can I get output like this:</p>

<p><strong>Apple</strong> It is red</p>

<p><strong>Banana</strong> It is yellow</p>

<p><strong>Mango</strong> It is green</p>

<p>Here is the full java file</p>

<pre><code> public class MainActivity extends Activity {

    TextView txtv, txt1;
    ImageView imgv;


       // List view
    private ListView lv;

    // Listview Adapter
    ArrayAdapter&lt;String&gt; adapter;

    // ArrayList for Listview
    ArrayList&lt;HashMap&lt;String, String&gt;&gt; productList;

     ArrayList&lt;String&gt; products = new ArrayList&lt;String&gt;();


    /** 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&lt;String&gt; products) {        

             products.add("&lt;b&gt;Apple&lt;/b&gt; It is red");
             products.add("&lt;b&gt;Banana&lt;/b&gt; It is yellow");
             products.add("&lt;b&gt;Mango&lt;/b&gt; It is green");
              }

             private void addAsimB(ArrayList&lt;String&gt; products) {

                 products.add("&lt;b&gt;Flower&lt;/b&gt; It is nice");
                 products.add("&lt;b&gt;Fog&lt;/b&gt; It is white");
                 products.add("&lt;b&gt;Rose&lt;/b&gt; 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&lt;String&gt;(this, R.layout.list_item, R.id.product_list,   products);
                    lv.setAdapter(adapter);                

         }
    }
</code></pre>

<p>XML file for text view is here:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

    &lt;!-- Product Name --&gt;

     &lt;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" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>If anybody want the file: <a href="http://www.mediafire.com/?op37c1itodd8724" rel="nofollow">http://www.mediafire.com/?op37c1itodd8724</a></p>
