我对android很新.现在我构建一个小应用程序.
我需要在2.2中更改android默认查找的外观和感觉.所以,在这里我尝试更改选项卡的背景.你能帮帮我吗?
我喜欢使用xml/style的方式.
这就是我需要的实际输出.

可能重复:
C++构造函数名后的冒号是做什么的?
我在网上找到了下面的例子,但是构造函数的语法让我有点困惑,特别是:符号.有人可以给我一个简短的解释吗?谢谢.
struct TestStruct {
int id;
TestStruct() : id(42)
{
}
};
Run Code Online (Sandbox Code Playgroud) 我可以从我的构建脚本中引用connectedCheck任务(来自android插件):
connectedCheck.finalizedBy AndroidShowTestResults
Run Code Online (Sandbox Code Playgroud)
但是尝试使用connectedDebugAndroidTest(也来自android插件)
connectedDebugAndroidTest.finalizedBy AndroidShowTestResults
Run Code Online (Sandbox Code Playgroud)
给我
错误:(48,0)无法在项目':app'上找到属性'connectedDebugAndroidTest'.
如果我试试
task connectedDebugAndroidTest << {print '123'}
Run Code Online (Sandbox Code Playgroud)
它诅咒我
错误:无法添加任务':app:connectedDebugAndroidTest'作为具有该名称的任务已存在.
我不明白为什么我不能参考connectedDebugAndroidTest?
可用的gradle任务如下所示:
我有一个编译时间问题。刚接触 C++,所以我相信这很简单。我得到了当前的错误。
diarydb.cpp: In function ‘bool editdate(int, mysqlpp::Connection&)’: diarydb.cpp:413:
error: ‘format_tests’ has not been declared
Run Code Online (Sandbox Code Playgroud)
但是 diardby.cpp 我在这里声明了 format_tests
namespace format_tests {
bool testdateformat(string &date);
bool tesettimeformat(string &time);
bool lengthcheck(string &in,int length);
}
Run Code Online (Sandbox Code Playgroud)
和
bool format_tests::testdateformat(string &date){
// tests format of dat input for MYSQL form at of YYYY-MM-DD
// Need to tweak regex to restrict 0 < MM < 12 and 0 < DD <31.
const boost::regex e("\\d{4}\\x2D\\d{2}\\x2D\\d{2}");
return boost::regex_match(date,e);
}
Run Code Online (Sandbox Code Playgroud)
此处调用的编译器编译器。
bool dbsetget::editdate(int e_id,mysqlpp::Connection &con){
char evdate[11];
cout …Run Code Online (Sandbox Code Playgroud) 在我的布局文件中,我正在尝试使用以下语法来指定内部文本TextView:
android:text="@{user.isMe() && user.status.isEmpty() ? @string/EmptyStatusHint : user.status}"/>
Run Code Online (Sandbox Code Playgroud)
我得到了:
[致命错误] fragment_user_profile.xml:142:58:实体名称必须紧跟实体引用中的"&".
在数据绑定指南中没有什么特别之处.
所以,关于这种情况,我有两个问题:
在我的项目中,大多数对象都是在竞技场中创建的,并且保证它们在用户会话期间存在.因此,某些类将const引用作为成员字段是非常安全的,例如:
class A {
public:
A(const string& str) : str_(str) {}
private:
const string& str_;
};
Run Code Online (Sandbox Code Playgroud)
但这里有一个陷阱.错误地,可以创建A以下方式的实例:
A a("some temporal string object");
Run Code Online (Sandbox Code Playgroud)
在该行中,临时string对象已被隐式创建和销毁.因此,a存储不正确的参考.
如何防止这种行为?如果它导致编译错误会更好......
我有这样的方法:
std::unique_ptr<const Stats> Table::GetStats() const {
std::unique_ptr<Stats> result;
// ...
// Prepare stats. Under some conditions an exception may be thrown.
// ...
return result;
}
Run Code Online (Sandbox Code Playgroud)
问题是它不能编译:
错误:无法将'std :: unique_ptr'左值绑定到'std :: unique_ptr &&'
我可以使用以下旁路进行编译:
return std::unique_ptr<const Stats>(result.release());
Run Code Online (Sandbox Code Playgroud)
但这似乎有点过分.我无法理解,从C++的角度看第一段代码有什么问题?有更优雅的解决方案吗?
假设有类:
struct A {
int a;
virtual size_t GetMemoryUsage() const {
return sizeof(*this);
}
};
struct B : public A {
int b;
};
Run Code Online (Sandbox Code Playgroud)
并且可能存在更深层次的继承.
我想要的是有一个方法,它将返回一个对象在内存GetMemoryUsage()中占用的字节数,在这种情况下.通常它可以通过使用来实现sizeof(*this).问题是(至少AFAIU),我必须覆盖每个派生类中的方法,并实际复制粘贴其正文.我不喜欢重复的代码:)
我对么?如何通过仅从基类的方法调用它们来创建sizeof(*this)和decltype(*this)返回我想要的子类?有更优雅的解决方案吗?
我有两个解决方案,它们之间有什么区别?
解决方案1:
public static void main(String[] args) {
int i, j;
for (i = 0; i < 5; i++) {
for (j = 0; j <= i; j++) {
System.out.println(" * ");
}
System.out.println("\n");
}
}
Run Code Online (Sandbox Code Playgroud)
解决方案2:
public static void main(String args[]) {
int num = 0;
while (num < 5) {
for (int i = 0; i <= num; i++) {
System.out.print(" " + "*" + " ");
}
System.out.print("\n");
num++;
}
}
Run Code Online (Sandbox Code Playgroud)
两者都打印出不同的结果.任何人都可以解释一下原因吗?
我正在我计算的弧度值上实现Math.sin(),并且想知道是否有任何技术原因我从java获得的数字不同于我的计算器.相关代码:
public static double sin(double angle){
angle = Math.toRadians(angle);
return Math.sin(angle);
}
Run Code Online (Sandbox Code Playgroud)
输入:35
输出:0.573576436351046
据谷歌预计产量:-0.42818266949
我只是打印返回的值.有谁能告诉我?
我想知道是否有可能编写一个模板类,在其编译版本中设置了不同的成员.
例如,如何使用继承实现它:
/// These statistics are supported for all data types
struct StatsBase {
size_t count;
virtual void Describe() { print(count); }
};
/// These can describe almost all data types, but not all of them
template<DataType data_type>
struct StatsMinMax : public StatsBase {
CppType<data_type> min;
CppType<data_type> max;
void Describe() override {
StatsBase::Describe();
print(min);
print(max);
}
};
/// These are for numeric data types only
template<DataType data_type>
struct StatsAll : public StatsMinMax<data_type> {
CppType<data_type> sum;
void Describe() override {
StatsMinMax<data_type>::Describe(); …Run Code Online (Sandbox Code Playgroud) c++ ×6
c++11 ×4
android ×3
java ×2
android-tabs ×1
const ×1
decltype ×1
for-loop ×1
gradle ×1
inheritance ×1
namespaces ×1
reference ×1
return ×1
sfinae ×1
sizeof ×1
struct ×1
trigonometry ×1
unique-ptr ×1
while-loop ×1
xml ×1