我有一个CoordinatorLayout,我有我的按钮:
<android.support.design.widget.CoordinatorLayout
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="match_parent"
android:layout_gravity="bottom|end">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/icon"
app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
然后我有Activity xml,其中包含Button:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
<include
android:id="@+id/fabHere"
layout="@layout/fab_here"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在这里,我有一个Butterknife片段:
public class MyFragment extends Fragment {
....
@BindView(R.id.fab) FloatingActionButton fab;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.my_fragment, container, false);
ButterKnife.bind(this, view);
return view;
}
...
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我启动应用程序,则会出现:
java.lang.IllegalStateException:找不到字段为'fabHere'的ID为2131624072的必需视图'fab'.如果此视图是可选的,请添加"@Nullable"(字段)或"@Optional"(方法)注释.
我试图添加'@Nullable'和'@Optional'注释,但它不起作用
是否可以使用android导航组件从抽屉布局中打开片段来更改过渡效果。android 文档中没有任何内容。
有人知道如何在Flutter中动态地将更多行添加到DataTable中。如您所见,我的代码非常“硬编码” [行:11-31]。
应该有一种方法可以摆脱编写越来越多的DataRows的麻烦。
码:
class DataTableWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DataTable(
columns: [
DataColumn(label: Text('Patch')),
DataColumn(label: Text('Version')),
DataColumn(label: Text('Ready')),
],
rows: <DataRow>[
DataRow(
cells: <DataCell>[
DataCell(Text('AAAAAA')),
DataCell(Text('1')),
DataCell(Text('Yes')),
],
),
DataRow(
cells: <DataCell>[
DataCell(Text('BBBBBB')),
DataCell(Text('2')),
DataCell(Text('No')),
],
),
DataRow(
cells: <DataCell>[
DataCell(Text('CCCCCC')),
DataCell(Text('3')),
DataCell(Text('Yes')),
],
),
],
);
}
}
Run Code Online (Sandbox Code Playgroud) 我想使用Streams和Lambdas.但是如何用它重写我当前的方法呢?
public double calculate() {
double result = 0.0;
if (!mediumList.isEmpty()) {
Iterator<Medium> it = mediumList.iterator();
while (it.hasNext()) {
result= result+ it.next().getAge();
}
result = result / mediumList.size();
}
return result;
}
Run Code Online (Sandbox Code Playgroud) java ×3
android ×2
butterknife ×1
dart ×1
flutter ×1
java-8 ×1
java-stream ×1
kotlin ×1
lambda ×1
xml ×1