Changing a divider with setDivider in a ListActivity without a custom ListView?

前端 未结 3 1637
无人共我
无人共我 2021-02-01 07:53

I can\'t seem to get a customized divider, using a Drawable I\'ve defined, to work when using a ListActivity and not creating a custom ListView. It al

3条回答
  •  忘了有多久
    2021-02-01 08:47

    To set divider in listview programatically:

    These code put inside in your .java Class

       ListView lv = (ListView) findViewById(R.id.lv);
       lv.setDivider(getResources().getDrawable(R.drawable.drawable_divider));
       lv.setDividerHeight(1);
    

    Creating Drawable: {res > drawable > drawable_divider.xml}

    
    
    
        
    
    
    

提交回复
热议问题