The canonical bases of cluster algebras of finite types and rank 2 are given explicitly in cite{CK2005} and cite{SZ} respectively. In this paper, we will deduce $mathbb{Z}$-bases for cluster algebras for affine types $widetilde{A}_{n,n},widetilde{D}$ and $widetilde{E}$. Moreover, we give an inductive formula for computing the multiplication between two generalized cluster variables associated to objects in a tube.