我是Android开发的新手,我想首先让Hello World应用程序运行.我正在使用Eclipse IDE和Android 4.0.3版本15 SDK.我从教程站点复制了所有内容,但是当我尝试运行应用程序时,virtual device我收到此错误:
[2012-02-01 11:31:23 - Android_test] Installation error: INSTALL_FAILED_OLDER_SDK
[2012-02-01 11:31:23 - Android_test] Please check logcat output for more details.
[2012-02-01 11:31:23 - Android_test] Launch canceled!
Run Code Online (Sandbox Code Playgroud)
这是我的com.maze.app包中的类:package com.maze.app;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
Run Code Online (Sandbox Code Playgroud)
和AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maze.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我构建的Web服务创建一个简单的Android客户端,但在运行时出现问题.
这是客户:
public class MyClient extends AsyncTask<EditText, Integer, String> {
private EditText text;
protected String doInBackground(EditText... strings) {
RuntimeDelegate
.setInstance(new com.sun.ws.rs.ext.RuntimeDelegateImpl());
WebResource wbr;
Client client = Client.create();
wbr = client
.resource("http://my.ip:8080/MazeService/rest/service/hello");
String result = wbr.queryParam("number", "10")
.accept(MediaType.APPLICATION_JSON).get(String.class);
text = strings[0];
return result;
}
protected void onProgressUpdate(Integer... progress) {
// setProgressPercent(progress[0]);
}
protected void onPostExecute(String result) {
if (result != null)
this.text.setText(result);
else
Log.d("MyApp", "No Result");
}
Run Code Online (Sandbox Code Playgroud)
}
和服务:
@Path("/service")
public class AndroidService {
@GET
@Produces(MediaType.APPLICATION_JSON )
@Path("/hello")
public String getJSON(@QueryParam("number") …Run Code Online (Sandbox Code Playgroud) 我是Android的新手,所以这个问题可能有一个简单的答案(我可能错过了一些东西).我试图在Google的Resting框架的帮助下创建一个REST客户端(因为Jersey似乎不起作用).当我尝试运行客户端时,我收到此警告:
W/System.err(728): java.net.UnknownHostException: Unable to resolve host "my.ip:8080": No address associated with hostname
然后我得到一些例外,但我想这是根本原因.
我有互联网许可:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maze.client"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".RestingClientActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
如果您需要任何其他信息,请告诉我们.
我正在使用Jersey服务和客户端.当我试图调用该服务时,我收到此错误:
Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: GET http://localhost:8080/Maze/rest/service/overview?countryid=1 returned a response status of 204 No Content
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:528)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:674)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:503)
at com.maze.client.MyClient.overviewTest(MyClient.java:34)
at com.maze.client.MyClient.main(MyClient.java:64)
Run Code Online (Sandbox Code Playgroud)
我不懂为什么.
这是服务:
@GET
@Produces(MediaType.APPLICATION_JSON )
@Path("/overview")
public JSONArray getOverviewEntities(@QueryParam("countryid")String id){
JSONArray array = null;
try{
Integer countryId = Integer.parseInt(id);
ArrayList<Event> list = new ArrayList<Event>();
EventService event = new EventService();
EntityManagerSingleton.getInstance().getTransaction().begin();
list.addAll(event.getList(countryId, "country", 5));
EntityManagerSingleton.getInstance().getTransaction().commit();
for(Event ev : list){
array.add(EventService.toJSONObject(ev));
}
} catch(Exception e){
e.printStackTrace();
}
return array;
}
Run Code Online (Sandbox Code Playgroud)
这是客户:
public …Run Code Online (Sandbox Code Playgroud) I am using Datatables, a jQuery plugin for creating custom tables. I am trying to create now a table with many columns, at least one of them containing a lot of text. The problem is that the column with long text is not created wider, but taller, making the table more difficult for the user to read.
How can I make the text column wider and less higher?
Here is a screenshot with my problem:

Here is my problem …
我正在尝试使用 ExtJS 4.1 创建一个网格面板。它使用 AJAX 代理从服务器获取数据:
var store = Ext.create('Ext.data.Store', {
model: 'myModel',
pageSize: pageSize,
proxy: {
type: 'ajax',
url: "../search",
actionMethods: {
create: "POST",
read: "POST",
update: "POST",
destroy: "POST"
},
headers: {
'Content-Type': 'application/json'
},
limitParam: false,
startParam: false,
pageParam: false,
extraParams: JSON.stringify({
rows: pageSize,
role: "Admin",
index: myIndex,
question: searchPhrase
}),
reader: {
type: 'json',
root: 'results.results',
totalProperty: 'numFound',
model: 'myModel'
}
}
});
store.loadPage(1);
Run Code Online (Sandbox Code Playgroud)
但它似乎不起作用。
我收到一条错误消息,指出无法读取 JSON。更重要的是,在 Firebug 中,发送的参数不是人类可读的。
当我尝试使用相同的参数进行 Ajax 调用时,一切似乎都正常:
Ext.Ajax.request({
url:"../search",
method: "POST", …Run Code Online (Sandbox Code Playgroud) 我试图捕获bad_alloc异常,以证明使用析构函数.
这是我的对象:
#include "Obj.h"
#include<iostream>
using namespace std;
Obj::Obj() {
d = new double[200000000];
}
Obj::~Obj() {
cout << "destroyed \n";
}
Run Code Online (Sandbox Code Playgroud)
主要方法:
#include "Obj.h"
#include <iostream>
using namespace std;
int main(){
Obj* ptr[1000000];
try{
for(int i=0; i<1000; i++){
ptr[i] = new Obj();
}
} catch(bad_alloc){
cout<<"EXCEPTION";
}
}
Run Code Online (Sandbox Code Playgroud)
我的程序不再捕获异常,而是停止并尝试在线查找解决方案(Windows).为什么会这样?
编辑 我现在得到异常,但我应该证明在抛出异常之前使用了析构函数.我该怎么办?
我试图了解JPA的工作原理.据我所知,如果你持有一个实体,该对象将保留在内存中,直到应用程序关闭.这意味着,当我查找以前持久化的实体时,将不会对数据库进行查询.假设没有进行插入,更新或删除,如果应用程序运行的时间足够长,则其中的所有信息可能会持久化.这是否意味着在某些时候,我将不再需要数据库?
编辑
我的问题不在于数据库.我确信无法从应用程序外部修改数据库.我自己管理事务,所以数据一提交就会存储在数据库中.我的问题是:我提交后实体会发生什么?它们是否保存在内存中并像缓存一样?如果是这样,他们在那里待了多久?在我提交之后persist,我进行select查询.这个选择应该返回我之前持久化的对象.该对象是从内存中获取的,还是应用程序会查询数据库?
我是Android新手.我想要做的是当我按下按钮并在文本字段中写入字符串时,通过Web服务获取String.
Manifext.xml:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidClientActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
main.xml中:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="myClickHandler"
android:text="Button" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
strings.xml中:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<string name="hello">Hello World, AndroidClientActivity!</string>
<string name="app_name">AndroidClient</string>
<string name="button">Message</string>
<string name="myClickHandler">myClickHandler</string>
Run Code Online (Sandbox Code Playgroud)
AndroidClientActivity.class:
package com.maze.client;
import javax.ws.rs.core.MediaType;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource; …Run Code Online (Sandbox Code Playgroud) 我正在运行ExtJS 4.1应用程序.它在FireFox中运行得很好,但我在Internet Explorer 8中遇到此错误:Could not complete the operation due to error 80020101.
我找到了各种可能的修复方法,但似乎没有一个能够满足我的需求.
如何使应用程序在IE8中运行?
我正在尝试使用 SPARQL 查询删除一些三元组。
delete ?s ?p ?o {<http://www.example.org/test/unit213> ?p ?o.
?s ?p ?o}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
执行查询失败:错误的查询:解析错误:意外的终端变量名(值:?s)。预期终端:({ qname qname_ns q_iri_ref 来自数据)。
问题是什么?
我使用EclipseLink作为JPA提供程序.
我想进行查询以获取IDs与在线一个Criteria查询对应的所有名称.
Root<UserAccount> root = criteria.from(UserAccount.class);
List<Selection<?>> select = new ArrayList<Selection<?>>();
for (MyElement element : list) {
Expression<String> firstName = root.get("firstName");
Expression<String> lastName = root.get("lastName");
Expression<Integer> id = root.get("id");
select.add(criteria
.multiselect(
firstName.alias(element.getId() + "_"
+ element.getEntity() + "f"),
lastName.alias(element.getId() + "_"
+ element.getEntity() + "l"))
.where(criteriaBuilder.equal(id, element.getAuthorId()))
.from(UserAccount.class)
.alias(element.getId() + "_" + element.getEntity()));
}
criteria.multiselect(select);
TypedQuery<Tuple> q = em.createQuery(criteria);
for (Tuple t : q.getResultList()) {
for (OverviewEntity element : list) {
System.out.println("////"
+ t.get(element.getId().toString() + "_"+element.getEntity()+"f",
String.class));
Run Code Online (Sandbox Code Playgroud)
通过 …
我在HTML页面中有以下元素:
<body>
<div style="height:100%; width:100%">
<div style="height:100px;"></div>
<div id="container" style="height:25%; width:50%">
</div>
Run Code Online (Sandbox Code Playgroud)
现在我想container使用jQuery(或纯JavaScript)获得div的高度(以像素为单位).我该怎么做?
$('#container').height() // returns `0`
Run Code Online (Sandbox Code Playgroud)