我需要在类中构建<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
指针,这将在构造类时创建。
我的代码是:
TextView textView = FindViewById<TextView>(Resource.Id.textView);
textView.TextFormatted = Html.FromHtml("Please read our " +
"<a href=\"http://www.xamarin.com\">Rules and Conditions</a> " +
"before using app.");
textView.MovementMethod = LinkMovementMethod.Instance;
但是得到ostream
我不知道为什么。请帮帮我。
答案 0 :(得分:0)
您在代码中犯了以下错误: 你&#34;重新宣布&#34;你的&#34;输出&#34; - 在构造函数中变量 - 所以指针ios只存储在构造函数范围内的局部变量中。
更改此行:ostream * output_ = new std :: ostream(&amp; fb); into:* output_ = new std :: ostream(&amp; fb);
这样,你的类的成员变量就会被correkt指针填充。
答案 1 :(得分:-1)
您可以更改您的construtor功能,如下所示:
test2_t () : output_(new std::ofstream("dump.txt")) {
}
不要忘记在析构函数中释放资源:
virtual ~test2_t () {
delete output_;
}