我有一个包含4列的数据库:
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL("CREATE TABLE " + DATABASENAME + " (name TEXT, latitude REAL, longitude REAL, country TEXT);");
}
Run Code Online (Sandbox Code Playgroud)
现在我想添加另一列,但保留已存在于数据库中的行.我该怎么做?我找不到任何有用的参考资料.
@Override
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
//What to do here?
}
Run Code Online (Sandbox Code Playgroud)
编辑
我已将onCreate修改为:
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL("CREATE TABLE " + DATABASENAME + " (name TEXT, latitude REAL, longitude REAL, country TEXT, code TEXT);");
}
Run Code Online (Sandbox Code Playgroud)
和我的onUpgrade:
@Override
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
Logger.log("Updating userstations database from …Run Code Online (Sandbox Code Playgroud) 在IE 11中使用signalR时会发生奇怪的行为.场景:
我们有一些调度程序类型的功能,其中调度程序执行某些操作,而另一个用户可以实时查看更新(查询).发送的参数很好,可以在IE客户端进行更新,而无需打开开发人员控制台.
但是一个不起作用的方法(performUpdate- 获取查询结果 - 这是服务器>客户端调用,而不是客户端>服务器>客户端) - 永远不会被调用.当开发者控制台打开时,它只会得到打电话.
这是我尝试过的:
为什么JavaScript只在IE中打开开发人员工具一次后才有效?
SignalR:在IE9下,客户端无法接收消息,直到我点击F12 !!!!
一些代码片段
调度员方面
在下拉列表更改时,我们获取当前选定的值并通过网络发送更新.(这很好).
$('#Selector').on('change', function(){
var variable = $('#SomeField').val();
...
liveBatchHub.server.updateParameters(variable, ....);
});
Run Code Online (Sandbox Code Playgroud)
服务器端
当调度程序搜索时,我们会有一些服务器端代码发送已运行搜索的通知,并告诉客户端提取结果.
public void Update(string userId, Guid bId)
{
var context = GlobalHost.ConnectionManager.GetHubContext<LiveBatchViewHub>();
context.Clients.User(userId).performUpdate(bId);
}
Run Code Online (Sandbox Code Playgroud)
客户端(实时更新的查看者)
除非开发者工具是开放的,否则永远不会调用
liveBatchHub.client.performUpdate = function (id) {
//perform update here
update(id);
};
Run Code Online (Sandbox Code Playgroud)
编辑
一些可能有用的信息(我不确定它为什么会产生影响)但这只会在我做服务器>客户端调用时发生.当调度程序更改搜索参数时,更新是客户端>服务器>客户端或调度程序客户端>服务器>查看器客户端,这似乎有效.单击搜索后,搜索管道中的服务将调用performUpdate服务器端(server> viewer-client).不确定这是否重要?
编辑2和最终解决方案
眼睛充血,我意识到我遗漏了这个问题的一个关键部分:我们在这个页面上也使用了角度.猜猜我已经盯着它看了太久而把它留了出去 - 抱歉.我给了JDupont答案,因为他在正确的轨道上:缓存.但不是jQuery的ajax缓存,角度$ http.
就这样,没有人不得不花费数天/晚的时间将头撞在桌子上,最终的解决方案是禁用使用angulars $ http的ajax调用缓存.
取自这里:
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there …Run Code Online (Sandbox Code Playgroud) 要么我错过了一些核心概念,这些概念深埋在一些文档中(Spring,Spring Boot,H2,HSQLDB,Derby,IntelliJ),或者我已经盯着这个太久了.
我有一个Spring Boot项目.尝试首先使用和初始化H2数据库,尝试在IntelliJ中连接它只是为了意识到我可能无法轻松浏览数据库而不放弃我的长子(使用IntelliJ数据库客户端连接到H2数据库).
所以我搬到了DerbyDB.同样的事情 - db root文件夹是在我的应用程序中创建的,我在IntelliJ中连接到它,但我刚刚启动应用程序创建的表格无法浏览.
我甚至尝试过SQLite,但对SQLite的支持不是很好,并且某些更新功能不可用,但我至少可以在IntelliJ浏览器中找到我的表格!
我只想要一个简单的单个文件嵌入式数据库,我可以轻松地使用,浏览和播放.有什么建议?!
当我运行应用程序时,我看到模式已导出:
2015-07-19 09:37:45.836 INFO 98608 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
Hibernate: drop table user_roles if exists
Hibernate: drop table users if exists
Hibernate: create table user_roles (id bigint generated by default as identity, role_name varchar(255), version bigint, user_id bigint, primary key (id))
Hibernate: create table users (id bigint generated by default as identity, email varchar(255), password varchar(255), username varchar(255), version bigint, primary key (id)) …Run Code Online (Sandbox Code Playgroud) 新的反应和反应路由器.
我试图理解这个例子:
https://github.com/ReactTraining/react-router/blob/1.0.x/docs/API.md#components-1
但是this.props从不包含main或sidebar.我的代码:
Main.js
ReactDOM.render(
<Router>
<Route path="/" component={App2}>
<Route path="/" components={{main: Home, sidebar: HomeSidebar}}/>
</Route>
</Router>,
document.getElementById('content')
);
Run Code Online (Sandbox Code Playgroud)
App2.js
class App2 extends React.Component {
render() {
const {main, sidebar} = this.props;
return (
<div>
<Menu inverted vertical fixed="left">
{sidebar}
</Menu>
<Container className="main-container">
{main}
</Container>
</div>
);
}
}
export default App2;
Run Code Online (Sandbox Code Playgroud)
Home.js
import React from 'react';
class Home extends React.Component {
render() {
return (
<div><h1>Home</h1></div>
);
}
}
export default Home;
Run Code Online (Sandbox Code Playgroud)
HomeSidebar.js
class HomeSidebar extends React.Component { …Run Code Online (Sandbox Code Playgroud) 我正在以编程方式创建一个listiview.我在listview元素之间保留了一个分隔符.我希望保留一个透明的分隔符,因为我有一个背景图像要显示.我尝试了以下不起作用的代码.请帮助
setListAdapter(new ArrayAdapter<String>(this,R.layout.news,news));
ListView lv=getListView();
ColorDrawable sage= new ColorDrawable(this.getResources().getColor(Color.TRANSPARENT));
lv.setDivider(sage);
lv.setDividerHeight(20);
Run Code Online (Sandbox Code Playgroud) 我有一个继承自Hub类的NotificationHub类.
public class NotificationHub : Hub
{
public void Send(string userId, Notification notification)
{
Clients.User(userId)
.notificationReceived(notification);
}
}
Run Code Online (Sandbox Code Playgroud)
这总是失败的
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.AspNet.SignalR.Hubs.SignalProxy.Invoke(String method, Object[] args) +88
Microsoft.AspNet.SignalR.Hubs.SignalProxy.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) +12
CallSite.Target(Closure , CallSite , Object , <>f__AnonymousType0`4 ) +351
Run Code Online (Sandbox Code Playgroud)
但是,如果我这样做:
public class NotificationHub : Hub
{
public void Send(string userId, Notification notification)
{
var context = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
context.Clients.User(userId)
.notificationReceived(notification);
}
}
Run Code Online (Sandbox Code Playgroud)
它有效....这里给出了什么?我见过的大多数例子都不需要明确地获取上下文,如果Hub尚未提供它?我宁愿不必每次都明确地抓住它.
这是我的IoC设置:
GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => new SimpleInjectorHubActivator(container)); …Run Code Online (Sandbox Code Playgroud) 最初我收到了这个错误:
指定的子项已有父项.您必须首先在孩子的父母上调用removeView()
在
customSection.addView(customLayout);
Run Code Online (Sandbox Code Playgroud)
所以我补充道
((LinearLayout)customLayout.getParent()).removeView(customLayout);
Run Code Online (Sandbox Code Playgroud)
现在得到
java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
因此,如果孩子有父母,我必须先从父母那里删除孩子,为什么getParent()会返回null?
我有一个抽象的片段,允许派生类为列表适配器提供自定义布局.相关代码:
捆绑:
public void bind(DataObject row) {
View customLayout = getChildItemView(row);
if (customLayout != null) {
((LinearLayout) customLayout.getParent()).removeView(customLayout);
customSection.removeAllViews();
customSection.addView(customLayout);
customSection.setVisibility(View.VISIBLE);
} else {
customLayout.setVisibility(View.INVISIBLE);
}
}
protected View getChildItemView(CommonRow row) {
if (parentView == null) {
parentView = (LinearLayout) LayoutInflater.from(getActivity())
.inflate(R.layout.list_item_custom_section,
new LinearLayout(getActivity()), true);
label = (TextView) parentView.findViewById(R.id.txtData1Label);
value = (TextView) parentView.findViewById(R.id.txtData1Value);
}
label.setText("Minimum");
value.setText(manager.formatMoney(((SpecificDataRow) row).minimum));
return parentView;
}
Run Code Online (Sandbox Code Playgroud)
我也试过inflater.inflate(R.layout.list_item_custom_section, null)......假,空/假,是什么给出的?
编辑:
@allprog,我知道需要一些清理工作.我在一天结束时写了这篇文章有点匆忙.我已经清理了代码,并分离出视图的绑定和膨胀.清理代码:
private class ViewHolder {
.... …Run Code Online (Sandbox Code Playgroud) 我试图更好地了解如何使用material-ui的FormControl或TextField组件检查脏点.TextField演示页面的文档说明:
TextField由较小的组件(FormControl,InputLabel,Input和FormHelperText)组成,您可以直接利用它们来显着自定义表单输入.
...并在TextField API文档中声明:
<FormControl />组件的属性也可用.
...稍后在FormControl API文档中指出:
提供表单输入的脏 /聚焦/错误/所需的上下文.依赖于上下文提供了高灵活性,并确保状态始终与FormControl的子项保持一致.此上下文由以下组件使用:
FormLabel FormHelperText输入InputLabel
但我没有看到任何文档说明如何使用TextField/FormControl检查脏.
任何人都可以澄清吗?这是StackOverflow,所以这里是我正在使用的TextField的一些代码:
<TextField
id='email'
label='Email'
value={this.state.email}
onChange={this.handleChange('email')}
margin="normal"
required
fullWidth>
</TextField>
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有一个文件:
private File TEMP_PHOTO_FILE = new File(Environment.getExternalStorageDirectory(), "temp_photo.jpg");
Run Code Online (Sandbox Code Playgroud)
这是在我的班级中直接声明的,并且对于那里的所有方法都是可见的.
我想用这个:
Bitmap thePhoto = BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString());
Run Code Online (Sandbox Code Playgroud)
Uri.fromFile(TEMP_PHOTO_FILE).toString()生成字符串:"file:///mnt/sdcard/temp_photo.jpg"
为什么这不起作用?似乎因为我们正在处理文件,所以应该有一些decodeFile()接受URI作为输入的方法.由于不一致,不允许这样做非常令人沮丧.
我已经使用HMR / React Hot Reloader进行了所有工作,因为它与视图有关。但是在添加了redux,react-redux等之后,每当我修改视图或化简器时,都会出现以下错误:
<Provider> does not support changing `store` on the fly. It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. See https://github.com/reactjs/react-redux/releases/tag/v2.0.0 for the migration instructions.
遵循错误中的链接会导致有2年的历史,关于明确使用replaceReducer的帖子,这就是我所做的。
我的版本:
“ redux”:“ ^ 3.7.2”“ react-redux”:“ ^ 5.0.6”
我感觉这主要是由于我对我的module.hot.accept调用的位置和放置方式缺乏了解(如果可以包含多个呢?)。相关代码如下。
boot.js(入口点)
import { Provider } from 'react-redux';
import { AppContainer } from 'react-hot-loader';
import { ConnectedRouter } from 'react-router-redux';
import App from './App';
import …Run Code Online (Sandbox Code Playgroud) android ×4
reactjs ×3
javascript ×2
signalr ×2
asp.net-mvc ×1
ecmascript-6 ×1
h2 ×1
iis ×1
image ×1
material-ui ×1
react-redux ×1
react-router ×1
redux ×1
spring ×1
spring-boot ×1
sqlite ×1
webpack-hmr ×1