http://m.blog.csdn.net/blog/tcgwl/14450547
出自:http://blog.csdn.net/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