我正在尝试实施+========================================================+
| Sensor | Value | Quality | Quality L1 | Quality L2 |
+--------+----------+----------+------------+------------+
| F3 | -768 | 5672 | None | Excellent |
| FC5 | 603 | 7296 | None | Excellent |
| AF3 | 311 | 7696 | None | Excellent |
| F7 | -21 | 296 | Nothing | Nothing |
| T7 | 433 | 104 | Nothing | Nothing |
| P7 | 581 | 7592 | None | Excellent |
| O1 | 812 | 7760 | None | Excellent |
| O2 | 137 | 6032 | None | Excellent |
| P8 | 211 | 5912 | None | Excellent |
| T8 | -51 | 6624 | None | Excellent |
| F8 | 402 | 7768 | None | Excellent |
| AF4 | -52 | 7024 | None | Excellent |
| FC6 | 249 | 6064 | None | Excellent |
| F4 | 509 | 5352 | None | Excellent |
| X | -2 | N/A | N/A | N/A |
| Y | 0 | N/A | N/A | N/A |
| Z | ? | N/A | N/A | N/A |
| Batt | 82 | N/A | N/A | N/A |
+--------+----------+----------+------------+------------+
|Packets Received: 3101 | Packets Processed: 3100 |
| Sampling Rate: 129 | Crypto Rate: 129 |
+========================================================+
。我有NavigationView
我要添加ToolBar
。我不确定为什么它不可见。
ActionBarDrawerToggle
public class DashboardActivity extends BaseActivity {
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mActionBarDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityDashboardBinding activityDashboardBinding = setContentView(this, R.layout.activity_dashboard);
// setting the toolbar title
setToolbarText(getString(R.string.home_screen_name));
// initializing drawer layout and action bar toggle
mDrawerLayout = activityDashboardBinding.drawer;
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.home_screen_open_drawer, R.string.home_screen_close_drawer) {
@Override
public void onDrawerClosed(View drawerView) {
// Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
// Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank
super.onDrawerOpened(drawerView);
}
};
//Setting the actionbarToggle to drawer layout
mDrawerLayout.addDrawerListener(mActionBarDrawerToggle);
//calling sync state is necessay or else your hamburger icon wont show up
mActionBarDrawerToggle.syncState();
}
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mActionBarDrawerToggle.syncState();
}
}
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.icici.iciciappathon.dashboard.DashboardActivity">
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/first"
layout="@layout/toolbar"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<include
android:id="@+id/content_get_started"
layout="@layout/content_get_started" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/titleToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/all_toolbar" />
</android.support.v7.widget.Toolbar>
</merge>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/history"
android:checked="false"
android:title="@string/login_client_id" />
</group>
</menu>
public class BaseActivity extends AppCompatActivity {
private AppCompatTextView mAppCompatTextView;
private ProgressDialog mProgressDialog;
private Toolbar mToolbar;
private String accessToken;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
// register device with firebase
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
public <T extends ViewDataBinding> T setContentView(Activity mActivity, int layoutResID) {
T viewDataBinding = DataBindingUtil.setContentView(mActivity, layoutResID);
getToolbar();
return viewDataBinding;
}
/**
* Show a progress dialog.
*
* @param msg
*/
protected void showProgress(String msg) {
if (mProgressDialog != null && mProgressDialog.isShowing())
dismissProgress();
mProgressDialog = ProgressDialog.show(this, getResources().getString(R.string.app_name), msg);
}
/**
* Show progress dialog.
*/
protected void dismissProgress() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
/**
* Show a toast.
*
* @param msg the text to show
*/
protected void showToast(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
/**
* Show a alert dialog.
*
* @param msg the text to show
*/
protected void showAlert(String msg) {
final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.Theme_AppCompat_Light_Dialog_Alert));
builder.setTitle(getResources().getString(R.string.app_name))
.setMessage(msg)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).create().show();
}
/**
* Show a alert dialog to check out bought items.
*
* @param msg the text to show
*/
protected void showAlertAndStartActivity(final Context context, String msg, final Intent intent) {
final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.Theme_AppCompat_Light_Dialog_Alert));
builder.setTitle(getResources().getString(R.string.app_name))
.setMessage(msg)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
// start check out activity for payment
startActivity(intent);
((Activity) context).finish();
}
}).create().show();
}
protected Toolbar getToolbar() {
if (mToolbar == null) {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
if (mToolbar != null) {
setSupportActionBar(mToolbar);
}
}
return mToolbar;
}
protected void showToolbar() {
mToolbar.setVisibility(View.VISIBLE);
}
protected void setToolbarText(String title) {
AppCompatTextView toolbarTitle = (AppCompatTextView) mToolbar.findViewById(R.id.titleToolbar);
toolbarTitle.setText(title);
}
protected void hideToolbar() {
mToolbar.setVisibility(View.GONE);
}
protected String getAccessToken() {
return accessToken;
}
protected void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
protected boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) this.getSystemService(
Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo() != null &&
cm.getActiveNetworkInfo().isConnectedOrConnecting();
}
}
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:buttonStyle">@style/ICICIAppathonButton</item>
</style>
答案 0 :(得分:1)
替换此行
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.home_screen_open_drawer, R.string.home_screen_close_drawer)
用这个
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolBar,R.string.home_screen_open_drawer, R.string.home_screen_close_drawer)
希望这会有所帮助!