我正在为我的应用程序制作一个图标..该应用程序基本上是一个朋友查找器.我创建的叠加层看起来很像谷歌纵横的图标.我有一个图像,由于用户而改变,我有寄宿生.我已经能够分层绘制和叠加精细,但问题是,图像延伸到边框的大小.这是一个问题,因为如果你从未见过Google Lat图标,它底部有一个点,它之间有空隙.
我需要做的是,以某种方式将变化图像的大小限制为边框的方形部分的边界.任何帮助将非常感激.这是我的片段:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 25;
Bitmap bit = BitmapFactory.decodeFile(photo, options);
draw = new BitmapDrawable(bit);
Resources r = getResources();
Drawable[] layers = new Drawable[2];
layers[0] = draw;
layers[1] = r.getDrawable(R.drawable.border);
LayerDrawable layerDrawable = new LayerDrawable(layers);
draw = layerDrawable;
}else{
draw = this.getResources().getDrawable(R.drawable.androidmarker);
}
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(draw, this);
GeoPoint point = new GeoPoint(lat,lon);
OverlayItem overlayitem = new OverlayItem(point, username, avail + " : " + status + " : Position updated at : " …Run Code Online (Sandbox Code Playgroud) 我正在创建一个Web服务来查询我的数据库并返回数据库中对象的列表.我收到错误:NullPointerAccess:变量"varname"在此位置只能为null.无论我把变量放在哪里,我都会得到相同的警告.无论我放在变量中,它都返回null.以下是它出现的方法:
public List<Contacts> getUsers()
{ String test = null;
String username = "root";
String password = "ticket";
String tablename = "users";
String fieldname = "*";
String query = "SELECT " + fieldname + " FROM " + "android." + tablename + ";";
Contacts cont = new Contacts();
List<Contacts> lstc = null;
/* this chnk of code can appear more or less verbatim */
/* in your database apps (including JSPs) */
String url = "jdbc:mysql://"my IP address":3306/android";
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection …Run Code Online (Sandbox Code Playgroud) 我正在将一些代码输入到Ubuntu框中运行的Hudson Server上,以便在代码上运行一些代码度量(Sonar)和Cobertura.该项目运行Glassfish3.1,使用Maven3,用Java编写,JSF 2.0并使用OracleXE数据库(不相关).
尝试在JUnit测试中创建Facade实例时,会抛出错误.当我从Netbeans运行它们时,测试运行正常,但是当Hudson自动构建它时,我得到了这个错误:
java.lang.ClassCastException: $Proxy96 cannot be cast to ticket.app.DatesFacade
at ticket.app.EventsControllerTest.setUp(EventsControllerTest.java:60)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:207)
at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:107)
at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Run Code Online (Sandbox Code Playgroud)
Hudson服务器不是从JBoss运行的,它是由Tomcat运行的.我添加了这个细节,因为当我谷歌这个错误时,除了JBoss错误之外,我什么都没发现,这个错误解释了在WAR和EAR文件中都引用了facade.
编辑:这是我目前正在创建Facade的实例(通过Netbeans GF3.1运行测试时工作正常):
Map properties = new HashMap();
properties.put(EJBContainer.MODULES, new File("target/classes"));
properties.put("org.glassfish.ejb.embedded.glassfish.configuration.file", "server/config/domain.xml");
properties.put("oracle.jdbc.OracleDriver", "server/lib/ojdbc14.jar");
ejbContainer = …Run Code Online (Sandbox Code Playgroud) 我需要一些澄清; 我有一个我建立的jar,在jar里面它有一个application-context.xml我需要加载的自定义文件.我在jar内的类中加载文件.当我设置这个application-context.xml的url时,是我的jar的类路径特有的目录,还是使用jar-classpath的项目?
例如 -
Jar的类路径:
src > main > META-INF > application-custom-context.xml
Run Code Online (Sandbox Code Playgroud)
项目的类路径:
src > Libraries > myjar.jar > src > main > META-INF > application-custom-context.xml
Run Code Online (Sandbox Code Playgroud)
我知道这些网址不准确:P - 但是,在我的上下文创建中,我会遵循哪个目录结构.这都是理论上的.今天有人问我这个,我不知道怎么回答.我认为如果你从一个jar调用一个类,类路径应该相对于那个jar的内容..但是,我认为远非总是正确的:)