我生成一个SQLite表(在java中):
create table participants (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, col1,col2);
Run Code Online (Sandbox Code Playgroud)
之后我尝试使用INSERT命令添加行:
insert into participants values ("bla","blub");
Run Code Online (Sandbox Code Playgroud)
我收到错误:
java.sql.SQLException: table participants has 3 columns but 2 values were supplied
Run Code Online (Sandbox Code Playgroud)
我以为行ID会自动生成,但似乎我错过了任何东西.
我试过另一个解决方案
PreparedStatement prep = conn.prepareStatement("insert into participants values (?,?,?);");
Integer n = null;
prep.setInt(1,n);
prep.setString(2, "bla");
prep.setString(3, "blub");
prep.addBatch();
prep.executeBatch();
Run Code Online (Sandbox Code Playgroud)
结果我收到了"prep.setInt(1,n);"的空指针异常.
你看到了错吗?
每当文件被添加到特定文件夹(例如下载文件夹)时,我都希望收到一个事件.为了达到这个目的,我尝试了3种不同的方法但没有成 目标设备是Android 15+.您是否对这3种方法中的任何一种方法有任何经验并且可以帮助提供工作样本?
方法1 - FileObserver:
在后台服务我添加了一个递归文件观察员顶层文件夹描述这里.在Android 4/5上它的工作但在Android 6上没有事件被触发(已知问题)最重要的是,在Android 4/5上,文件观察者似乎不可靠.在某些时候,会调用stopWatching()方法,从那时起不会收到任何事件.
在onStartCommand(..)的服务:
new MyFileObserver(Constants.DOWNLOAD_PATH, true).startWatching();
Run Code Online (Sandbox Code Playgroud)
方法2 - 内容观察员:
我试图调整内容观察员我的使用情况(如描述在这里),但我从来没有收到任何事件.
在onStart服务:
getContentResolver().registerContentObserver( Uri.parse("content://download/"), true,
new MyObserver(myHandler));
Run Code Online (Sandbox Code Playgroud)
.
public class MyObserver extends ContentObserver {
// left blank below constructor for this Contact observer example to work
// or if you want to make this work using Handler then change below registering //line
public MyObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange) {
this.onChange(selfChange, null);
Log.e("", …Run Code Online (Sandbox Code Playgroud) 我想将Google Play帐户集成到Firebase.在我们公司,只有我的老板拥有谷歌游戏帐户的所有者权限.用于firebase和adsense等其他工具的帐户具有管理员权限.
是否可以在此设置中将Google Play帐户集成到firebase?我该怎么做?
我有一个Android项目依赖于actionbar sherlock.它编译没有错误,但运行按钮被禁用.我有另一个运行良好的Android项目并在我的设备上运行,但我看不出这些项目之间的区别 - 除了我能够运行一个项目而我无法运行另一个项目.
我会提供截图,但实际上我不知道这个问题的位置.
任何的想法?
不知何故,渐弱边缘似乎不适用于Android ics(android 4+)自己的视图.如果我在较低的Android版本上测试这个布局,它会描绘淡化边缘但不会在android 4.1上.
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdge="vertical"
android:focusableInTouchMode="true" <-- does not make any change
android:focusable="true" <--
/>
Run Code Online (Sandbox Code Playgroud)
有没有解决方法?
我正在设计一个拖放操作,但我不知道如何访问我的数据.有没有人使用Clip Data对象?这是我的代码:
开始拖放:
ClipData dragData= ClipData.newPlainText("my", "test") );
v.startDrag(dragData,
new MyDragShadowBuilder(v),
v, 0);
Run Code Online (Sandbox Code Playgroud)
听取事件:
case DragEvent.ACTION_DROP:{
if (event.getClipDescription().getLabel().equals("my"))
Log.d("myLog","Data:"+event.getClipData()+" "+event.getClipData().getItemCount());
Run Code Online (Sandbox Code Playgroud) 我有x个提升线程同时工作.一个生产者线程使用计算任务填充同步队列.消费者线程弹出任务并计算它们.
图片来源:https://www.quantnet.com/threads/c-multithreading-in-boost.10028/
用户可以在此过程中完成程序,因此我需要正确关闭我的线程.我当前的方法似乎不起作用,因为抛出异常.它的目的是在系统关闭时,所有进程都应该被杀死并且无论他们做什么都会停止当前的任务.你能告诉我,你怎么会杀掉线程?
线程初始化:
for (int i = 0; i < numberOfThreads; i++)
{
std::thread* thread = new std::thread(&MyManager::worker, this);
mThreads.push_back(thread);
}
Run Code Online (Sandbox Code Playgroud)
线程破坏:
void MyManager::shutdown()
{
for (int i = 0; i < numberOfThreads; i++)
{
mThreads.at(i)->join();
delete mThreads.at(i);
}
mThreads.clear();
}
Run Code Online (Sandbox Code Playgroud)
工人:
void MyManager::worker()
{
while (true)
{
int current = waitingList.pop();
Object * p = objects.at(current);
p->calculateMesh(); //this task is internally locked by a mutex
try
{
boost::this_thread::interruption_point();
}
catch (const boost::thread_interrupted&)
{
// Thread …Run Code Online (Sandbox Code Playgroud) 我喜欢将本地时间格式格式化为没有年份的字符串.目前我能够显示包含年份的本地格式:
java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
String dateString = df.format(date);
Run Code Online (Sandbox Code Playgroud)
因此我收到一个时间字符串输出,如
12.03.2012
03/12/2012
Run Code Online (Sandbox Code Playgroud)
对于不同的国家.现在我想得到一个简短的表格
12.03.
03/12
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
谢谢你的帮助!
在我的应用程序中,我有不同的主题 - 一种黑暗主题和一种明亮主题。每个主题都需要自己的图标集。
如何将其应用到主题中?是否有类似特殊文件夹之类的东西,用于不同大小的图标?
我可以更改导航微调器的背景:
<style name="MyTheme" parent="android:style/Theme.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav" parent="android:style/Widget.Spinner">
<item name="android:background">@drawable/spinner_white</item>
<item name="android:textColor">@color/red</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然而textColor没有改变.我还尝试了其他方法来更改textColor:
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">?color_actionbar</item>
<item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
</style>
<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/violet</item>
</style>
Run Code Online (Sandbox Code Playgroud)
还有其他想法吗?
android ×6
java ×2
boost ×1
c++ ×1
clip ×1
date-format ×1
download ×1
fileobserver ×1
firebase ×1
google-play ×1
layout ×1
localization ×1
sqlite ×1
themes ×1