How to add bulleted list to android application?

后端 未结 17 1377
抹茶落季
抹茶落季 2020-11-29 19:14

I have googled my question but there is not working answer provided. How do add a bulleted list to my textview.

17条回答
  •  死守一世寂寞
    2020-11-29 19:44

    I find this to be the easiest way, leave the textView as it is in the xml file and use the following java code. it worked perfectly fine for me.

    private static final String BULLET_SYMBOL = "•";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tutorial);
    
        TextView tv = (TextView) findViewById(R.id.yourTextView);
    
        tv.setText("To perform this exercise you will need the following: "
                            + System.getProperty("line.separator")//this takes you to the next Line
                            + System.getProperty("line.separator")
                            + Html.fromHtml(BULLET_SYMBOL + " Bed")
                            + System.getProperty("line.separator")
                            + Html.fromHtml(BULLET_SYMBOL + " Pillow"));
    }
    

提交回复
热议问题