0

I have a horizontal listview of text. I want to add COLORED BULLET POINTS in between those texts. I used Gallery to display horizontal listview. The final view should be same as in the image. Also, how to get a divider like in the image between the Gallery and textview?

Activity

public class MainActivity extends Activity {
 
  Gallery myHorizontalListView;
  MyAdapter myAdapter;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  myHorizontalListView = (Gallery)findViewById(R.id.horizontallistview);
      
       myAdapter = new MyAdapter(this);
       myHorizontalListView.setAdapter(myAdapter);
      
       myHorizontalListView.setOnItemClickListener(new OnItemClickListener(){
  
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
      long id) {
     Toast.makeText(MainActivity.this, parent.getItemAtPosition(position).toString() + " Clicked", Toast.LENGTH_LONG).show();
      
    }});
      
   }
  
   public class MyAdapter extends BaseAdapter {
     
    Context context;
     
    String[] itemsArray = {
      "SUN","MON", "TUS", "WED", "THU", "FRI", "SAT"};
     
    MyAdapter(Context c){
     context = c;
    }
  
   @Override
   public int getCount() {
    // TODO Auto-generated method stub
    return itemsArray.length;
   }
  
   @Override
   public Object getItem(int position) {
    // TODO Auto-generated method stub
    return itemsArray[position];
   }
  
   @Override
   public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
   }
  
   @Override
   public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
     
    View rowView = LayoutInflater
      .from(parent.getContext())
      .inflate(R.layout.row, null);
    TextView listTextView = (TextView)rowView.findViewById(R.id.itemtext);
    listTextView.setText(itemsArray[position]);
     
    return rowView;
   }
    
    
   }
 }

I'm Trying to achieve like this

Sammy
  • 181
  • 3
  • 18
  • Possible duplicate of [How do I add a bullet symbol in TextView?](http://stackoverflow.com/questions/3429546/how-do-i-add-a-bullet-symbol-in-textview) – rahul Jan 06 '16 at 07:37
  • I tried that but the bullet color is black and I want colored bullet. For that I'm using shape in xml. I just need to know how to insert them in between texts. @Rahul. – Sammy Jan 06 '16 at 07:42

1 Answers1

1

Use drawableLeft property for adding bullets in textview

as for xml

android:drawableLeft="your_file"

also in your view first image has no bullet then in code put check that

if(position == 0)
listTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
Amarjit
  • 4,327
  • 2
  • 34
  • 51