【发布时间】:2017-02-23 07:19:44
【问题描述】:
我在 Xamarin Android 上有 2 个活动。请注意,第二个设置为以对话框形式打开。
[Activity(Label = nameof(ActivityOne), HardwareAccelerated = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class ActivityOne : Activity { ... }
[Activity(Label = nameof(ActivityTwo), HardwareAccelerated = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait, Theme = "@android:style/Theme.Holo.Dialog")]
public class ActivityTwo : Activity { ... }
第一个这样调用第二个:
var activity = new Intent(this, typeof(ActivityTwo));
StartActivity(activity);
当第二个活动打开时,我希望能够在对话框上动态设置标题。
我尝试在创建第二个活动时这样做:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ActivityTwo);
SetTitle(Resource.Id.title);
...
}
其中 title 被定义为 ActivityTwo.axml 中的“隐藏”文本视图:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title"
android:text="Example Title"
android:visibility="gone" />
但这就是我在运行应用程序时得到的对话框标题:
同样没有 SetTitle 行,标题只是“ActivityTwo”。谁能帮我解决这个问题?
【问题讨论】:
标签: xamarin.android