Snackbar 与 Toast 小区别:
Snackbar activity消失后不显示内容 Toast activity消失后仍显示内容
Androidstudio中的命名
Androidstudio中的布局文件和drawable中不允许出现大写命名的ID
Androidstudio下Module的导入步骤
file—import module —找到路径—导入—在build.gradle(app)下—添加compile project(‘:module名’)
使用Fragment小心导包出错
导包一定要一致,例如要导包import android.support.v4.app.Fragment;就全部导这个包,要导import android.app.Fragment;包就全部导这个包
截取字符串
substring
public String substring(int beginIndex, int endIndex) 返回一个新字符串,它是此字符串的一个子字符串。该子字符串从指定的 beginIndex 处开始, endIndex:到指定的 endIndex-1处结束。 示例: “hamburger”.substring(3,8) returns “burge” “smiles”.substring(0,5) returns “smile” 参数: beginIndex - 开始处的索引(包括)。 endindex 结尾处索引(不包括)。 返回: 指定的子字符串。 抛出: IndexOutOfBoundsException - 如果 beginIndex 为负,或length大于字符串长度。
将毫秒转换为年月日的代码段
long time = questionInfo. getTime() ;
Date date = new Date (time);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd" );
holder. tv_question_time. setText(simpleDateFormat. format(date ));
JSON数据中有HTML标签的解析
Spanned news_message_fromHtml = Html.fromHtml(news_message);//参数是接受的JSON数据
int数据的传递及获取
Intent intent=new Intent(this ,MyActivity.class );
intent.putExtra("intent_integer" ,300 );
startActivity(intent);
int i=getIntent().getExrtras ().getInt ("intent_integer" )