我有一个带有静态字段F的A类:
class A {
public static String F = null;
}
Run Code Online (Sandbox Code Playgroud)
B级:
class B extends A {
public static String F = "somestring";
}
Run Code Online (Sandbox Code Playgroud)
和一个使用字段F的方法的类型化的类:
class C<T extends A> {
public void someMethod() {
String someString = T.F;
// Manipulations with someString
}
}
Run Code Online (Sandbox Code Playgroud)
然后我的代码调用它.
C<B> c = new C<B>();
c.someMethod();
Run Code Online (Sandbox Code Playgroud)
当我尝试使用someString进行操作时,我得到一个空指针异常.所以,TF是null,但是T是B,所以它应该是"somestring"!为什么?
我的程序需要将大的.txt文件存储在SD卡上(因此,我想用.apk重新分发它,而无需从程序创建).如何将文件(在PC上创建)附加到.apk?
我有一个带有大量项目的微调器,因此简单的滚动对用户来说非常慢.我想在ScrollView中使用"Big"可触摸滚动条或类似滚动条.我该怎么做?
我正在尝试在VC++ 2010 Express中编译SymbolicC++库(在发行版中有特殊的VS项目),但它在系统头中提供了很多错误,与之相关operator,.例如:
1> C:\ Program Files\Microsoft Visual Studio 10.0\VC\include\xlocmon(410):错误C2593:'运算符',含糊不清
对于系统头中的此代码:
if (_Str[0] < _E0 || _E0 + 9 < _Str[0])
_Str2 += '-', ++_Off;
Run Code Online (Sandbox Code Playgroud)
为什么?怎么编译呢?
我已将库模块ActionBarSherlock包含到我的项目中.最小的SDK版本是10,目标SDK - 13用于这两个项目.
但是当我尝试构建项目时,我遇到了很多错误:
[Library] /Users/rankor777/src/ActionBarSherlock/library/res/values-v14/abs__styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.
Run Code Online (Sandbox Code Playgroud)
为什么?
我有一个类别表,其中"订单"列用于订购类别.我试图在插入之前在触发器中逐步设置顺序:
CREATE TRIGGER `categories_set_order` BEFORE INSERT ON `categories` FOR EACH ROW BEGIN
DECLARE max_order INT DEFAULT 0;
SELECT MAX(categories.order) INTO max_order FROM categories;
SET NEW.order = max_order + 1;
END;
Run Code Online (Sandbox Code Playgroud)
但是如果db中没有记录,则将order列设置为NULL.我修改了触发器代码:
CREATE TRIGGER `categories_set_order` BEFORE INSERT ON `categories` FOR EACH ROW BEGIN
DECLARE max_order INT DEFAULT 0;
SELECT MAX(categories.order) INTO max_order FROM categories;
IF (ISNULL(@max_order)) THEN BEGIN
SET max_order = 0;
END;
SET NEW.order = max_order + 1;
END;
And I'm getting the following error:
Error Code: 1064. You have …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码:
private void startForeground(boolean isActive) {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(getString(isActive ? R.string.title_agent_active : R.string.title_agent_inactive))
.setContentIntent(pendingIntent)
.build();
startForeground(1, notification);
}
Run Code Online (Sandbox Code Playgroud)
和
@Override
protected void onHandleIntent(Intent intent) {
startForeground(true);
...
Run Code Online (Sandbox Code Playgroud)
使用此代码通知不会出现.
但是如果我用NotificationManager.notify(...)替换startForeground(...) - 它会显示通知,所以,我认为,至少通知构建代码是可以的.
哪里可能是问题?
我有以下 VC:
中心的 VC 是“登录”屏幕,如果用户获得授权,它只是将用户重定向到选项卡栏控制器。
我想禁止从 TabBarController 中的任何 VC 返回登录 VC(使用“后退”按钮和滑动)。
如何实现这一目标?
我正在使用djangorestframework与以下代码:
class RegistrationView(APIView):
def post(self, request, format=None):
print self.request.META.get('API_KEY')
Run Code Online (Sandbox Code Playgroud)
然后它返回None(其他标题,如Content-Type或User-Agent可以).
但是这个标题肯定存在于请求中(这个键只有local-db,所以可以将它粘贴到这里):
为什么?
我的布局中有多个 TextInputLayouts,我需要验证字段(如果它们无效,则显示错误文本)。
但是TextView包含错误是由TextInputLayout动态添加的,因此它会更改布局高度,并且底部的所有视图都降低了 added 的高度TextView。
所以问题是:即使没有显示错误,我是否可以为错误文本保留空间?