あんなことを

a thing like that

→ あんな
phrase Rare #21,586
a thing like that Refers to an action or event considered unpleasant, surprising, or inappropriate, often with emotional distance or criticism. The を marks it as the object of the following verb.
JA: どうしてあんなことを言ったの?
EN: Why did you say a thing like that?

なぜ私はあんなことをしたのか

Why did I do such a thing?

あんなことを人に言われたのは初めてだ

That's the first time anyone's ever said something like that to me.

なんでトムさんはあんなことをしたのでしょう

I wonder why Tom did such a thing.

社長にあんなことを言ったからには僕はくびになるのは確実だ

Now that I’ve said something like that to the president, I’m sure to get fired.

トムさんはあんなことをいったはずがないと思います

I don't think Tom could have said such a thing.

あんなことをするなんて頭がどうかしている

You must be out of your mind to do something like that.

あんなことを言うと君も勇気がある

You’re pretty brave to say something like that.