答案 0 :(得分:2)
你可以在FrameLayout的帮助下完成它。
#include "stdafx.h"
#include <functional>
#include <iostream>
using namespace std::placeholders;
class Observable
{
public:
void Register(std::function<void()> Callback)
{
}
std::function<void()> OnStateChanged;
void ChangeState()
{
std::cout << "DevicioClient::ChangeState" << std::endl;
OnStateChanged();
}
};
class Observer
{
Observable client;
void OnStateChanged()
{
std::cout << "DevicioConsumer::OnStateChanged" << std::endl;
}
public:
void Run()
{
// does work
client.OnStateChanged = []{
std::cout << "client.OnStateChanged" << std::endl;
};
// doesn't work
// OnStateChanged = std::bind(&Observable::OnStateChanged, this);
client.ChangeState();
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Observer consumer;
consumer.Run();
getchar();
return 0;
}
答案 1 :(得分:0)
在TabLayout
旁边添加按钮是否有意义?管理它(只是一个alignParentRight
按钮和tabLayout to_leftOf
)要容易得多,结果也是一样的。