标签:ble 完成 this style 一个 mil icon ref das
【概述】
【Button】

<Button
android:id="@+id/testBtn"
android:layout_width="150dp"
android:layout_height="43dp"
android:onClick="onClick"
android:text="测试按钮"
tools:layout_editor_absoluteX="130dp"
tools:layout_editor_absoluteY="46dp" />
protected void onClick(View v){
switch (v.getId()){
case R.id.testBtn:
Toast.makeText(this, "测试按钮被点击", Toast.LENGTH_SHORT).show();
}
}
【Toast】
1). 消息展示的 Context 实例,一般指当前 Activity 实例;
2). 消息提示的内容:字符串格式,也可以写到 R资源中;
3). 消息提示的时间长度:Toast.LENGTH_SHORT 和 Toast.LENGTH_LONG
//用户点击返回键时触发
private static final int TIME_INTERVAL = 2000;
private long mBackPressed = 0;
public void onBackPressed(){
long cMills = System.currentTimeMillis();
if(cMills - mBackPressed > TIME_INTERVAL){//如果两次点击时间间隔超过 TIME_INTERVAL,则执行“提示退出”操作
mBackPressed = cMills;
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show();
}else{//如果两次点击在 TIME_INTERVAL 时间间隔内,则执行“退出”操作
super.onBackPressed();
}
}
【Menu】

创建 bottom_nav_menu.xml 完成。


<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/title_home" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="@string/title_dashboard" />
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_notifications" />
</menu>


<resources>
<string name="app_name">HelloWorld</string>
<string name="title_home">主页</string>
<string name="title_dashboard">导航</string>
<string name="title_notifications">通知</string>
</resources>
标签:ble 完成 this style 一个 mil icon ref das
原文地址:https://www.cnblogs.com/zlxyt/p/11125568.html