I have a watch app but am investigating replacing the activity with a system overlay window.
The standard way of inflating a wearable's layout is to use:
public class MyController : Controller
{
private IUserService1 _userService1;
private IUserService2 _userService2;
public MyController(IUserService1 userService1, IUserService2 userService2)
{
_userService1 = userService1;
_userService2 = userService2;
}
}
However, if I am no longer using the activity instead I will be creating the system overlay window in a server. Searching for how to do this all the answers suggest using WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
method. However that takes a resource as a parameter, not a resource id.
How can I a load the WatchViewStub without using findViewById()? Or is there a way of using findViewById() from within a service?
答案 0 :(得分:0)
You can call public int negamax(Result result, Token token) {
if (result == Result.WIN) {
return 1;
} else if (result == Result.DRAW) {
return 0;
}
int best = -1;
for (Coordinate move : Board.getAvailableMoves()) {
Token other = token.getOther();
Result r = Board.makeMove(move, other);
int eval = -negamax(r, other);
Board.unmakeMove(move);
if (eval > best) {
best = eval;
}
}
return best;
}
public Coordinate getNegamaxMove(Token token) {
int score = -1;
Coordinate bestMove = null;
for (Coordinate move : Board.getAvailableMoves()) {
Result result = Board.makeMove(move, token);
int newScore = negamax(result, token);
Board.unmakeMove(move);
if (newScore >= score) {
score = newScore;
bestMove = move;
}
}
return bestMove;
}
in the findViewById()
because you've set the content view (root view) via Activity
. Now, when you are inflating the view, you will inflate the setContentView()
that is a root, and then call View
on that layout, example:
findViewById()