730

Thursday, 10 April 2014

Add Bulleted list into Textview android application



First  of all you separate String by special character ,then after you store string into array list.Now use the "for-loop" for separate use bullet.Don't use Scrollview for adding  textview.



Features="String variable";
String [] values_comma = Features.split("\\.");

for(int i=0;i<values_comma.length;i++)
{
CharSequence cs = values_comma[i];

SpannableString ss = new SpannableString(cs);
ss.setSpan(new BulletSpan(15), 0, cs.length(), 0);
TextView tv = new TextView(this);
if(i%2==0)
{
tv.setBackgroundColor(Color.parseColor("#F1E5CA"));
}else
{
tv.setBackgroundColor(Color.parseColor("#EEC995"));
}

tv.setPadding(15, 15, 10, 15);
tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
tv.setText(ss);
feature_view_Linear.addView(tv);
}



As given below :


No comments:

Post a Comment