Some useful expressions

本文介绍了中国各种传统美食的英文名称,包括早餐、主食、面条、汤品、甜点等,帮助读者更好地向外国朋友介绍中国美食文化。

我们中国吃的文化是由来已久,但怎样把中国吃的文化介绍出去,怎样用英文来表达呢.虽然很多人喜欢以拼音来表达,但没吃过中国小吃的老外肯定是不能理解的。还是让我们一块来学习一下吧.
中式早點 烧饼     clay oven rolls              油条     fried bread stick
韭菜盒    fried leek dumplings        水饺     boiled dumplings


蒸饺     steamed dumplings         馒头     steamed buns
割包     steamed sandwich          饭团     rice and vegetable roll
蛋饼     egg cakes                   皮蛋     100-year egg
咸鸭蛋    salted duck egg             豆浆     soybean milk
     
饭 类
稀饭     rice porridge           白饭     plain white rice
油饭     glutinous oil rice       糯米饭    glutinous rice
卤肉饭    braised pork rice       蛋炒饭    fried rice with egg
地瓜粥    sweet potato congee

面 类
馄饨面    wonton & noodles      刀削面    sliced noodles
麻辣面    spicy hot noodles       麻酱面    sesame paste noodles
鴨肉面    duck with noodles      鱔魚面    eel noodles
乌龙面    seafood noodles       榨菜肉丝面  pork , pickled mustard green noodles
牡蛎细面   oyster thin noodles      板条     flat noodles
米粉     rice noodles             炒米粉    fried rice noodles
冬粉     green bean noodle

汤 类
鱼丸汤    fish ball soup            貢丸汤    meat ball soup
蛋花汤    egg & vegetable soup    蛤蜊汤    clams soup
牡蛎汤    oyster soup              紫菜汤    seaweed soup
酸辣汤    sweet & sour soup       馄饨汤    wonton soup
猪肠汤    pork intestine soup       肉羹汤    pork thick soup
鱿鱼汤    squid soup               花枝羹    squid thick soup

甜 点
爱玉     vegetarian gelatin       糖葫芦    tomatoes on sticks
长寿桃    longevity peaches       芝麻球    glutinous rice sesame balls
麻花     hemp flowers            双胞胎    horse hooves
冰 类
绵绵冰    mein mein ice           麦角冰    oatmeal ice
地瓜冰    sweet potato ice        紅豆牛奶冰  red bean with milk ice
八宝冰    eight treasures ice       豆花     tofu pudding

果 汁
甘蔗汁    sugar cane juice           酸梅汁    plum juice
杨桃汁    star fruit juice             青草茶    herb juice

点 心
牡蛎煎    oyster omelet        臭豆腐    stinky tofu (smelly tofu)
油豆腐    oily bean curd        麻辣豆腐   spicy hot bean curd
虾片     prawn cracker        虾球     shrimp balls
春卷     spring rolls           蛋卷     chicken rolls
碗糕     salty rice pudding    筒仔米糕   rice tube pudding
红豆糕    red bean cake        绿豆糕    bean paste cake
糯米糕    glutinous rice cakes  萝卜糕    fried white radish patty
芋头糕    taro cake             肉圆     taiwanese meatballs
水晶饺    pyramid dumplings    肉丸     rice-meat dumplings
豆干     dried tofu

其 他
当归鸭    angelica duck           槟榔     betel nut
火锅     hot pot
 

/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package androidx.databinding; import java.lang.annotation.ElementType; import java.lang.annotation.Target; /** * BindingAdapter is applied to methods that are used to manipulate how values with expressions * are set to views. The simplest example is to have a public static method that takes the view * and the value to set: * <p><pre> *<code>@BindingAdapter("android:bufferType") * public static void setBufferType(TextView view, TextView.BufferType bufferType) { * view.setText(view.getText(), bufferType); * }</code></pre> * In the above example, when android:bufferType is used on a TextView, the method * setBufferType is called. * <p> * It is also possible to take previously set values, if the old values are listed first: * <p><pre> *<code>@BindingAdapter("android:onLayoutChange") * public static void setOnLayoutChangeListener(View view, View.OnLayoutChangeListener oldValue, * View.OnLayoutChangeListener newValue) { * if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { * if (oldValue != null) { * view.removeOnLayoutChangeListener(oldValue); * } * if (newValue != null) { * view.addOnLayoutChangeListener(newValue); * } * } * }</code></pre> * When a binding adapter may also take multiple attributes, it will only be called when all * attributes associated with the binding adapter have binding expressions associated with them. * This is useful when there are unusual interactions between attributes. For example: * <p><pre> *<code>@BindingAdapter({"android:onClick", "android:clickable"}) * public static void setOnClick(View view, View.OnClickListener clickListener, * boolean clickable) { * view.setOnClickListener(clickListener); * view.setClickable(clickable); * }</code></pre> * The order of the parameters must match the order of the attributes in values in the * BindingAdapter. * <p> * A binding adapter may optionally take a class extending DataBindingComponent as the first * parameter as well. If it does, it will be passed the value passed in during binding, either * directly in the inflate method or indirectly, using the value from * {@link DataBindingUtil#getDefaultComponent()}. * <p> * If a binding adapter is an instance method, the generated DataBindingComponent will have * a getter to retrieve an instance of the BindingAdapter's class to use to call the method. */ @Target(ElementType.METHOD) public @interface BindingAdapter { /** * @return The attributes associated with this binding adapter. */ String[] value(); /** * Whether every attribute must be assigned a binding expression or if some * can be absent. When this is false, the BindingAdapter will be called * when at least one associated attribute has a binding expression. The attributes * for which there was no binding expression (even a normal XML value) will * cause the associated parameter receive the Java default value. Care must be * taken to ensure that a default value is not confused with a valid XML value. * * @return whether or not every attribute must be assigned a binding expression. The default * value is true. */ boolean requireAll() default true; } 翻译并注释
09-25
<think>好的,我现在需要处理用户的请求,翻译并注释一段关于Android DataBinding中BindingAdapter注解的代码。首先,我需要仔细阅读用户提供的代码和注释,确保理解每个部分的功能。 用户提供的代码是Android官方的BindingAdapter注解的源码,包含详细的Javadoc文档。用户要求翻译并添加注释,所以我的任务是将这段英文文档翻译成中文,并在代码中添加适当的注释,帮助理解每个部分的作用。 首先,我需要通读整个代码,了解整体结构。BindingAdapter注解用于标记那些用于处理数据绑定的方法,比如设置视图属性的方法。注解的参数包括value和requireAll,分别用于指定绑定的属性名称和是否所有属性都必须有绑定表达式。 接下来,我需要逐段翻译Javadoc中的内容,确保技术术语准确。例如,“bufferType”这样的专业术语需要保留,而“View.OnLayoutChangeListener”等类名也要正确翻译。同时,要注意代码示例中的Java代码块,确保在翻译过程中不破坏原有的代码结构。 在翻译过程中,可能会遇到一些需要特别注意的地方。例如,注解的@Target(ElementType.METHOD)部分,需要明确说明该注解只能应用于方法上。此外,requireAll参数的默认值是true,需要解释清楚其含义,即所有属性都必须有绑定表达式,否则方法不会被调用。 然后,我需要为代码添加注释。注释应该简洁明了,解释每个部分的作用。例如,在@Target注解处,可以添加注释说明该注解只能用于方法。在value()方法后,可以注释说明返回的属性数组用于关联绑定适配器与XML属性。 同时,需要注意用户提供的示例代码中的参数顺序问题,确保在注释中说明参数顺序必须与属性顺序一致。此外,关于DataBindingComponent的部分,需要解释其作用和使用场景,比如在需要依赖注入时如何使用。 在翻译和注释过程中,要确保技术准确性,避免误解原文。例如,原文中提到“A binding adapter may optionally take a class extending DataBindingComponent as the first parameter”,需要准确翻译为“绑定适配器可选地将DataBindingComponent的子类作为第一个参数”,并解释其用途。 此外,用户可能希望了解BindingAdapter的实际应用场景,比如如何在XML中使用这些绑定方法,以及需要注意的事项,如避免无限循环、类型安全等。虽然用户没有明确要求,但结合之前的对话历史,用户可能对实际应用有疑问,因此在注释中可以适当提及这些点。 最后,检查整个翻译和注释的流畅性,确保没有语法错误,技术术语一致,并且注释清晰易懂。例如,确认“requireAll”被正确翻译为“所有属性必须绑定”,并解释其默认行为。 总结来说,我需要分步骤处理:通读理解代码,逐段翻译文档,添加代码注释,确保技术准确性,并检查整体质量。同时,结合用户的历史问题,可能需要预测用户的后续问题,并在注释中提前解答,但根据当前任务,重点是完成翻译和注释。 </think>```java /* * 版权所有 (C) 2018 The Android Open Source Project * * 根据Apache许可证2.0版本授权 * 有关许可证的详细信息,请参阅 LICENSE 文件或访问: * http://www.apache.org/licenses/LICENSE-2.0 * * 文件说明:定义 @BindingAdapter 注解 * 用于标记数据绑定适配器方法,控制 XML 属性与 View 的绑定逻辑 */ package androidx.databinding; import java.lang.annotation.ElementType; import java.lang.annotation.Target; /** * 【核心注解】@BindingAdapter 用于标记数据绑定适配器方法 * 主要功能: * 1. 将 XML 属性映射到静态绑定方法 * 2. 支持多属性联合绑定 * 3. 允许处理新旧值对比 * * 示例1:基础用法 * <pre> *<code>@BindingAdapter("android:bufferType") * public static void setBufferType(TextView view, TextView.BufferType bufferType) { * view.setText(view.getText(), bufferType); * }</code></pre> * 当 XML 中 TextView 使用 android:bufferType 属性时,自动调用此方法 * * 示例2:带旧值处理 * <pre> *<code>@BindingAdapter("android:onLayoutChange") * public static void setOnLayoutChangeListener(View view, * View.OnLayoutChangeListener oldValue, // 自动传递旧值 * View.OnLayoutChangeListener newValue) { * if (API >= 21) { * if (oldValue != null) view.removeOnLayoutChangeListener(oldValue); * if (newValue != null) view.addOnLayoutChangeListener(newValue); * } * }</code></pre> * * 示例3:多属性联合绑定 * <pre> *<code>@BindingAdapter({"android:onClick", "android:clickable"}) * public static void setOnClick(View view, * View.OnClickListener clickListener, // 参数顺序必须与属性顺序一致 * boolean clickable) { * view.setOnClickListener(clickListener); * view.setClickable(clickable); * }</code></pre> */ @Target(ElementType.METHOD) // 仅允许注解在方法上 public @interface BindingAdapter { /** * 【必填参数】绑定的 XML 属性名称数组 * 示例:value = {"app:imageUrl", "app:errorImage"} * @return 属性名称数组 */ String[] value(); /** * 【可选参数】是否要求所有属性必须有绑定表达式 * true(默认):所有属性都必须有绑定表达式才会触发方法 * false:任意一个属性有绑定表达式就会触发方法 * 注意:未绑定的属性参数将收到 Java 默认值(如 null 或 false) * @return 是否要求所有属性必须绑定 */ boolean requireAll() default true; } ``` --- ### **核心概念解析** #### 1. **单属性绑定** ```java @BindingAdapter("app:customAttr") public static void setCustomAttr(View view, String value) { // 当 XML 中使用 app:customAttr="@{value}" 时触发 } ``` #### 2. **多属性绑定** ```java @BindingAdapter({"android:text", "android:textColor"}) public static void setTextAndColor(TextView view, String text, int color) { // 当同时设置 android:text 和 android:textColor 时触发 view.setText(text); view.setTextColor(color); } ``` #### 3. **旧值处理** ```java @BindingAdapter("app:imageUrl") public static void loadImage(ImageView view, String oldUrl, String newUrl) { if (!Objects.equals(oldUrl, newUrl)) { // 仅当 URL 变化时执行加载逻辑 Glide.with(view).load(newUrl).into(view); } } ``` #### 4. **DataBindingComponent 依赖注入** ```java @BindingAdapter("app:user") public static void setUser(TextView view, DataBindingComponent component, User user) { // 可通过 component 获取依赖项 view.setText(component.getUserFormatter().format(user)); } ``` --- ### **使用注意事项** 1. **方法签名规范** - 必须是 `public static` 方法 - 第一个参数必须是 View 类型(或其子类) - 多属性绑定时参数顺序必须与属性顺序一致 2. **性能优化** - 避免在绑定方法中执行耗时操作 - 对复杂计算建议使用 `@InverseBindingAdapter` 配合双向绑定 3. **命名冲突处理** - 不同类的同名属性绑定方法会被合并 - 建议使用模块前缀避免冲突(如 `app:customAttr` 而非 `android:customAttr`) 4. **默认值处理** - 当 `requireAll=false` 时,未绑定的参数会传入默认值(如 null、0、false) --- ### **典型应用场景** | 场景 | 实现方式 | 示例 | |------|----------|------| | 图片加载 | 自定义绑定方法封装 Glide | `app:imageUrl="@{viewModel.imageUrl}"` | | 状态同步 | 双向绑定处理 EditText | `@={viewModel.text}` | | 联合属性 | 多属性共同控制一个 View | `android:text+android:textColor` | | 动画控制 | 监听属性变化触发动画 | `app:animatePosition="@{position}"` | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值