我正在尝试设计 ui 页面,并且使用左侧和右侧的填充成功减少了底部导航栏的宽度。但问题是,如果我减少底部导航栏的宽度,那么它会在第二张图像(黑色箭头)中的导航栏的每个角上占用空间。下面我添加了代码和两个图像,第一个图像是来自 adobe xd 的图像,我试图实现此目的,第二个图像是在尝试减小底部导航栏的宽度之后。\n
\n
class _SettingsState extends State<Settings> {\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n body: Container(\n color: Colors.yellow,\n child: ListView(\n children: <Widget>[\n Padding(\n padding: const EdgeInsets.only(\n left: 8.0, right: 8.0, top: 65.0),\n child: TextField(\n decoration: new InputDecoration(\n isDense: true,\n hintText: "\xd8\xa7\xd8\xb3\xd9\x85\xd9\x83 (\xd8\xa7\xd8\xb3\xd9\x85 \xd8\xb5\xd9\x81\xd8\xad\xd8\xaa\xd9\x83)",\n fillColor: Colors.black,\n suffixIcon: Container(\n margin: EdgeInsets.only(bottom: 23),\n width: 0.1,\n alignment: Alignment.center,\n decoration: BoxDecoration(\n color: Colors.red,\n borderRadius: BorderRadius.circular(10),\n ),\n child: Text(\'\xd8\xaa\xd8\xb9\xd8\xaf\xd9\x8a\xd9\x84\', style: TextStyle(color: Colors.white),),\n ),\n ),\n keyboardType: TextInputType.text,\n style: new TextStyle(color: Colors.black),\n …Run Code Online (Sandbox Code Playgroud) 如何将数据从 recyclerview 适配器传递到片段以及我必须在片段中编写代码以接收数据。我已经检查了本网站中的链接,但不幸的是无法获得正确的代码。下面是代码
示例适配器.Java
public class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ExampleViewHolder> {
private ArrayList<ExampleItem> mExampleList;
@NonNull
@Override
public ExampleViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View v=LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.example_item,viewGroup,false);
ExampleViewHolder evh=new ExampleViewHolder(v);
return evh;
}
@Override
public void onBindViewHolder(@NonNull ExampleViewHolder exampleViewHolder, int i) {
final ExampleItem currentItem=mExampleList.get(i);
exampleViewHolder.mTextView.setText(currentItem.getmText());
exampleViewHolder.mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// pass the data to the fragment
}
});
}
@Override
public int getItemCount() {
return mExampleList.size();
}
public static class ExampleViewHolder extends RecyclerView.ViewHolder {
public TextView …Run Code Online (Sandbox Code Playgroud) 我创建了两个页面,第一页是显示图像和名称的主页,第二页是显示图像、名称和价格的详细信息页面。现在的问题是,如果我点击图像,它应该在第二页中显示图像、名称和价格,但它显示了一个错误类型“double”不是字符串类型的子类型,即使我试图将其转换为字符串。下面是两页和一个飞镖类模型的代码。
首页.dart
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();}
class _HomeState extends State<Home> {
List<Product> _product=[
Product(
name: "Small Cake",
image: "assets/1.png",
price: 50.00,
),];
@override
Widget build(BuildContext context) {
return PlatformScaffold(
body: ListView.builder(
itemCount: _product.length,
itemBuilder: (BuildContext context, int index) {
return Products(
product_image: _product[index].image,
product_name: _product[index].name,
product_price: _product[index].price,);}));}}
class Products extends StatelessWidget {
final product_name;
final product_image;
final product_price;
Products({this.product_name, this.product_image, this.product_price});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
top: 35.0, bottom: …Run Code Online (Sandbox Code Playgroud)