0
我必须编写一个代码来显示“internet not available”对话框在几个类文件中。据我所知,我需要写这个代码onCreate方法而已,但我的关注点是,代码重复执行。的代码如下代码重复
onCreate()
{
if(isNetworkStatusAvialable (getApplicationContext()))
{
showAlertDialog(HomeActivity.this, "Internet Connection",
"You have internet connection", true);
}
else
{
showAlertDialog(HomeActivity.this, "No Internet Connection",
"You don't have internet connection.", true);
}
}//End of oncreate
showAlertDialog(...................)
{
}
在几类文件相同的代码将被repeted。为了避免这种情况,如果我编写单独的类文件并将其扩展为“Extends”,那么我担心onCreate方法将通过所需的类文件重写,其中包含其他内容。
有任何建议。