http://m.blog.youkuaiyun.com/blog/tcgwl/14450547
出自:http://blog.youkuaiyun.com/krislight/article/details/11354119
项目中常会遇到的工具类 总结留存
首先Activity的抽象类 BaseActivity
项目中常会遇到的工具类 总结留存
首先Activity的抽象类 BaseActivity
-
- public
abstract class BaseActivity extends Activity { -
-
private static final String TAG = BaseActivity.class.getSimpleName(); -
-
public static int MSGTYPE_DEFAULT = 0; -
-
public static int MSGTYPE_INFO = 1; -
-
public static int MSGTYPE_WARNING = 2; -
-
public static int MSGTYPE_ERROR = 3; -
-
-
@Override -
protected void onCreate(Bundle savedInstanceState) { -
super.onCreate(savedInstanceState); -
} -
-
-
protected abstract void init(); -
-
-
protected abstract void initListener(); -
-
-
public String getResStr(int id) -
{ -
return this.getResources().getString(id); -
} -
-
-
protected void showShortToast(int resId) { -
Toast.makeText(this, getString(resId), Toast.LENGTH_SHORT).show(); -
} -
-
-
protected void showShortToast(String text) { -
Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); -
} -
-
-
protected void showLongToast(int resId) { -
Toast.makeText(this, getString(resId), Toast.LENGTH_LONG).show(); -
} -
-
-
protected void showLongToast(String text) { -
Toast.makeText(this, text, Toast.LENGTH_LONG).show(); -
} -
-
-
protected void showLogDebug(String tag, String msg) { -
Log.d(tag, msg); -
} -
-
-
protected void showLogError(String tag, String msg) { -
Log.e(tag, msg); -
} -
-
-
protected void startActivity(Class
本文总结了项目中常见的BaseActivity抽象类的使用方法,包括初始化、消息类型定义、资源字符串获取、提示框显示、日志记录等功能,并提供了具体的实现代码示例。

被折叠的 条评论
为什么被折叠?



