我显示了复选框的对话框(从DB检索的列表)以允许用户选择,删除哪些行.因为android对话框缓存,我需要刷新复选框的计数和名称.在我的onCreateDialog中:
dialog = new AlertDialog.Builder( this )
.setTitle( "Remove Items" )
.setMultiChoiceItems( items, _selections, new OnMultiChoiceClickListener(){public void onClick (DialogInterface dialog, int which, boolean isChecked){}} )
.setPositiveButton("Smazat", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
deleteRow(_selections);
} })
.setNegativeButton("Storno", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
} })
.create();
Run Code Online (Sandbox Code Playgroud)
如何在onPrepareDialog中刷新值(项目,_selections)?我尝试了无效的视图,希望强制android加载项目againg(不要既不工作),但我认为它的错误选择以及删除对话框和重新创建.
protected void onPrepareDialog(final int id, final Dialog dialog) {
switch (id) {
case REMOVE_DIALOG_ID:
ListView lv = ((AlertDialog) dialog).getListView();
lv.invalidateViews();
break;
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的任何想法!
我最近一直在学习OpenGL和SDL,而且我对SDL和glOrtho中的坐标系感到困惑.我已经阅读了一些关于SDL坐标系的教程,其中坐标从(0,0)到(w,h),这对我来说没有意义.如果宽度从0变为w,那么这意味着有一个额外的像素.
此外,使用OpenGL glOrtho函数,我已经看到所有将坐标系更改为类似于SDL的示例,采用以下形式:
glOrtho (0, screenWidth, screenHeight, 0, 1, -1);
Run Code Online (Sandbox Code Playgroud)
但是,这样做是否更有意义?:
glOrtho (0, screenWidth-1, screenHeight-1, 0, 1, -1);
Run Code Online (Sandbox Code Playgroud)
希望你们能为我澄清一下,谢谢.
我使用netbeans向导创建了实体bean,并尝试从数据库中获取数据.无论我使用什么SQL查询,它都不起作用.我尝试使用由向导创建的命名查询:
@NamedQuery(name = "Usr.findAll", query = "SELECT u FROM Usr u")
Run Code Online (Sandbox Code Playgroud)
它返回:
Caused by: Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Usr.findAll], line 1, column 0: unexpected token [Usr].
Run Code Online (Sandbox Code Playgroud)
如果我试试;
SELECT uid FROM usr;
Run Code Online (Sandbox Code Playgroud)
我明白了:
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT uid FROM usr;], line 0, column -1: unexpected end of query.
Internal Exception: MismatchedTokenException(-1!=78)
Run Code Online (Sandbox Code Playgroud)
即使我尝试:
SELECT * …Run Code Online (Sandbox Code Playgroud) 我目前正在为Android(API级别7)编写非常简单的游戏来发现和学习android SDK.此游戏涉及在屏幕上绘制形状,触摸时会改变颜色.
某些形状可能嵌入一个或多个孔.我的问题是:如果我触摸形状,整个事物的颜色变化,甚至是孔洞.这是我使用的伪代码,shape是我想绘制的多边形,边界是它的外边界,是一个洞的数组.洞和边界保持他们的点数组.
Path MyPath = Path();
Path.moveTo(boundary.points[0].x, boundary.point[0].x);
for (point in boundary) {
MyPath.lineTo(point.x, point.y);
}
Path.close();
for (hole in shape.holes) {
MyPath.moveTo(hole.points[0].x,hole.points[0].y);
for (point in hole) {
MyPath.lineTo(point.x, point.y);
}
MyPath.close();
}
// setting Paint here...
canvas.drawPath(MyPath, MyPaint);
Run Code Online (Sandbox Code Playgroud)
他们在Android中关于路径的东西是我缺少的,还是你有其他方法可以做到这一点?
我尝试在listView上使用marginBottom来在listView Item之间创建空格,但仍然将这些项连接在一起.
它甚至可能吗?如果是,是否有特定的方法来做到这一点?
我的代码如下
<LinearLayout
android:id="@+id/alarm_occurences"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
android:background="#EEEEFF"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/occurences"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的自定义列表项:
<com.android.alarm.listItems.AlarmListItem
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/alarm_item_background"
android:layout_marginBottom="10dp"
>
<CheckedTextView
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:textSize="20sp"
android:textStyle="bold"
android:typeface="serif"
android:padding="10dp"
/>
</com.android.alarm.listItems.AlarmListItem>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如何在列表项之间建立间距?
我正在建立一个带有Spring MVC的网站.由于我是Java EE的新手,我发现很难同时应用所有内容.
那么,我是否有可能开始使用简单的JDBC和spring构建应用程序,然后用hibernate替换它?
转移会更容易,所以我应该首先学习hibernate,然后从网站开始?
默认情况下,CKEditor的对话窗口显示在页面中间,但如果页面是高度较大的iframe,则对话框显示在页面的下方.
是否可以配置CKEditor将对话框放置在页面的不同象限中?例如中顶?
我有一些WCF服务.这些服务在ASP.NET中运行.我希望这些服务能够访问静态变量.我的问题是,我不确定适当的服务器级存储机制在哪里.我不想因为速度而使用数据库.但是,我希望静态变量尽可能长时间保留在内存中.事实上,如果可能的话,我希望它能保持到重新启动我的服务器.
任何人都可以提供任何想法吗?
我想在某个类的每个对象中添加唯一ID(在单个会话中).一种解决方案是使用工厂函数来增加一些静态计数器.一个更简单的解决方案是将此计数器添加到类本身,例如:
class fooWithUniqueId {
public:
fooWithUniqueId() : id(next_id++) {...};
long id;
private:
static long next_id = 0;
}
Run Code Online (Sandbox Code Playgroud)
然而,一个缺陷是该id领域是公开的,并且可以由呼叫者改变,从而违反其独特性.传统的(好吧,至少在我看来)是id私有,并使用getter函数来访问它,因此:
class fooWithUniqueId {
public:
fooWithUniqueId() : id(next_id++) {...};
long getId() const { return id; };
private:
long id;
static long next_id = 0;
}
Run Code Online (Sandbox Code Playgroud)
但我正在考虑采用不同的方法.我可以将id设为const公共类字段:
class fooWithUniqueId {
public:
fooWithUniqueId() : id(next_id++) {...};
const long id;
private:
static long next_id = 0;
}
Run Code Online (Sandbox Code Playgroud)
我更喜欢这种方式,因为getId()每次我需要id时都不需要继续调用,我可以将id用作映射中的键(因为复制构造正确初始化了复制对象的id).我能想到的一个缺点是我不能在fooWithUniqueId对象之间实现赋值,尽管目前我不需要这个功能.
谢谢,波阿斯