我正在使用const mysql = require('mysql');
module.exports.handler = (event, context, callback) => {
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: ''
});
//Destructing id from event.pathParameters object
var {id} = event.pathParameters
// Use the connection
connection.query('DELETE FROM sqllambdadb.contacts WHERE id=?', id, function (err, res) {
if (err) throw err;
else if (res.affectedRows>0) callback(err, 'EMail with ID: '+ id + ' deleted!');
else callback(err, 'No row with ID: '+ id + ' found!');
});
connection.end();
};
从清单文件中设置工具栏标题。
我想要设置一个自定义字体表单资产文件夹。
android:label="Setting"
这是我的工具栏:
<activity android:name=".Testingtoolbars"
android:label="Setting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
以下是我的活动:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:textAlignment="center"
android:fitsSystemWindows="true"
android:id="@+id/toolbar"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
我不想使用这样的自定义工具栏:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testingtoolbars);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
答案 0 :(得分:1)
1)在styles.xml中定义一个主题:
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:fontFamily">@font/fancy-font</item>
2)在工具栏布局中设置该主题:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:textAlignment="center"
android:fitsSystemWindows="true"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:theme="@style/ToolbarTheme"/>
对于较早版本的支持,请尝试:
toolbar.findViewsWithText(outViews, title, View.FIND_VIEWS_WITH_TEXT);
if (!outViews.isEmpty()) {
final TextView titleView = (TextView) outViews.get(0);
final Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams)
titleView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
titleView.setTypeface(Typeface);
toolbar.requestLayout();
}
希望有帮助。