change listview item background color c# code example

Example 1: how to change background color of list view in flutter

class PageTwoState extends State<PageTwo> {
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemExtent: 250.0,
      itemBuilder: (context, index) => Container(
            padding: EdgeInsets.all(10.0),
            child: Material(
              elevation: 4.0,
              borderRadius: BorderRadius.circular(5.0),
              color: index % 2 == 0 ? Colors.cyan : Colors.deepOrange,
              child: Center(
                child: Text(index.toString()),
              ),
            ),
          ),
    );
  }
}

Example 2: how to change background color of selected item in listview multichoice mode listener in android

android:background="?android:attr/activatedBackgroundIndicator"

Tags:

Misc Example