我正在尝试动态设置我在运行时充气的按钮的文本,但没有设置文本。
我正在创建一个自定义对话框,我在运行时为它设置SetContentView了一个View我在运行时膨胀的对话框。该视图包含一个Button,例如:
var dialog = new SetUnsetDialog();
var view = View.Inflate(_context, Resource.Layout.view_set_unset_buttons, null);
view.FindViewById<Button>(Resource.Id.btnPartsetA).Text = _blockDescriptions["partseta"];
dialog.SetContentView(view);
dialog.SetTitle("Set/Unset " + _area);
dialog.Show();
布局定义为:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <!-- irrelevant stuff removed -->
    <LinearLayout
        android:id="@+id/linearLayoutSetUnsetButtons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center">
        <!-- irrelevant stuff removed -->
        <Button
            android:id="@+id/btnPartsetA"
            android:background="@null"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:drawableTop="@drawable/partset_a" />            
        <!-- irrelevant stuff removed -->
    </LinearLayout>
</LinearLayout>
为什么没有设置按钮文本?我需要做什么来设置它?
更新:
事实证明,这不是问题。内容视图稍后会重置并覆盖我设置的值。