Here's how that happens.
Lithium oxide is formed due to the electrostatic force of attraction that exists between the lithium cations,
Lithium is located in group 1 of the Periodic Table, which means that it can complete its octet by giving up its sole valence electron
On the other hand, oxygen is located in group 16 of the Periodic Table, which means that it can complete its octet by taking in
Now, in order to have a neutral compound, the overall positive charge coming from the cation must be balanced by the overall negative charge coming from the anion.
In your case, you need
#2 * ["Li"]^(+) + ["O"]^(2-) -> "Li"_ 2"O"#
So, you can say that when lithium reacts with oxygen, every oxygen atom will take in two electrons, each provided by a lithium atom.
As a result, two lithium cations and one oxide anion, which represent a formula unit of lithium oxide, will be bonded ionically by the electrostatic force of attraction