nullpointerexception

NullPointerException when using ListView inside a ViewStub

为君一笑 提交于 2019-12-23 23:17:03
问题 I'm trying to create a ListView inside a ViewStub, but i keep on getting a NullPointerException . My Buttons works as intended inside the ViewStub. The code that fails is as following: else if(v.getId() == R.id.comments_button_series_view){ if(stubUsed == false){ stub = (ViewStub) findViewById(R.id.stub); View inflatedStub = stub.inflate(); String[] comments = new String[]{"comment1", "comment2"}; commentsAdapter = new ArrayAdapter<String>(this, R.layout.patient_list_element, R.id.comments

Why won't my code compile which checks if a string begins with vowel?

随声附和 提交于 2019-12-23 21:08:53
问题 if (flipped.charAt(0) = "a" || "e" || "i" || "o" || "u"){ paren = "(" + flipped; String firstpart = paren.substring(0,5); String rest = paren.substring(5); System.out.println(rest+firstpart); } In this code, I'm looking to check if the first character of String flipped is a vowel. If it is, I'm adding a parenthesis to the beginning and moving the first 5 characters to the end of the string. Eclipse is giving me java.lang.NullPointerException and saying that "The left-hand side of an

Why is registerForContextMenu passing onCreateContextMenu a null ContextMenuInfo?

守給你的承諾、 提交于 2019-12-23 19:51:06
问题 In onCreate, I attach a linear layout view to a variable activeView . I then call registerForContextMenu(activeView) . It appears that everything works properly, the context menu gets created, the items are clickable, however, in onContextItemSelected , I call AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo() and I get a nullpointerexception. I've traced the null menuInfo variable all the way back to find that registerForContextMeu(activeView) is passing

NullpointerException: cannot get property on null object

你离开我真会死。 提交于 2019-12-23 19:34:01
问题 Working on IDEA and trying to launch the following code: package com.myCompany.routing.spring import com.dropbox.core.DbxRequestConfig import grails.util.Holders import spock.lang.Specification class DropboxSpringConfigSpec extends Specification { def grailsApplication=Holders.grailsApplication def "It instantiates and configures the dropboxRequestConfig component"() { given: def ctx = grailsApplication.mainContext //do stuff... } } I get the following error: java.lang.NullPointerException:

How can I fix java.lang.NullPointerException caused by TraceGovernor in Jaspersoft studio plugin?

折月煮酒 提交于 2019-12-23 18:52:42
问题 I'm writing plugin for Jaspersoft studio up-to-date. The plugin crashes, when it is trying to open preview of report. (from the plugin) Stack Trace of java.lang.NullPoinpointerException: com.jaspersoft.studio.debug.TraceGovernor.setup(TraceGovernor.java:111) com.jaspersoft.studio.debug.TraceGovernor.initMaps(TraceGovernor.java:118) com.jaspersoft.studio.debug.TraceGovernor.beforeReportInit(TraceGovernor.java:162) net.sf.jasperreports.engine.fill.JRFillDatasetScriptlet.beforeReportInit

Reading a very large local XML file using GWT

拥有回忆 提交于 2019-12-23 18:49:44
问题 I am building my first Java application using GWT which must read in data from a very large XML file. I am having issues when I try sending a request for the information in the file, and I'm not quite sure if it has to do with the size of the file, or my semantics. In my program I have the following: static final String xmlurl = "filename.xml"; String xmlData; ... public void onModuleLoad() { requestData(xmlurl); if(xmlData.equals("Error")){ // display error message return; } else { //

View.findViewById() returning null

邮差的信 提交于 2019-12-23 12:17:30
问题 I have this code: private void inflateMenu() { if (menu == null) { mFanView = (LinearLayout) findViewById(R.id.fanView); final View v = LayoutInflater.from(getContext()).inflate( R.layout.sidemenu, mFanView); menu = (MenuView) v.findViewById(R.id.listViewMenu); } menu.setColors(backgroundColor, selectedColor, unselectedColor); } When debugging, v contains a MenuView whose id equals R.id.listViewMenu + 1 . Of course this will throw a NPE on menu.setColors. Why does R.id.listViewMenu contain an

Java isn't getting the file in the source code when compiled

与世无争的帅哥 提交于 2019-12-23 12:02:14
问题 Recently I have an issue with Java. I've tried some things I found on the web but they haven't worked, so I need help. I have a Java project in Eclipse. My main class is in src/programCode/UI_Main2.java . In that .java I try to access to a file in src/files/File.file And this is when the things fo weird. If I use /src/files/File.file it gives me NoSuchFileException . If I use src/files/File.file it works in Eclipse but when I compile it to a executable .jar it gives me NoSuchFileException .

NullPointerException at org.hibernate.ejb.criteria.path.AbstractPathImpl.get [duplicate]

和自甴很熟 提交于 2019-12-23 10:07:54
问题 This question already has answers here : JPA/Hibernate Static Metamodel Attributes not Populated — NullPointerException (8 answers) Closed 2 years ago . This works fine: public Predicate toPredicate(Root<Campaign> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return root.get("campState").get("statusId").in(campStatus); } but I change to : return root.get(Campaign_.campState).get(CampState_.campId).in(campStatus). And it throws exception: edit for: NullPointerException at org.hibernate

Setting android:versionName as reference to string resource leads to NullPointerException under the emulator

孤人 提交于 2019-12-23 07:56:11
问题 I'm trying to set the android:versionName in my android manifest as a reference to string resource stored in external resource file. Below is an excerpt from my AndroidManifest.xml : <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.toycorporation" android:versionCode="@integer/version_code" android:versionName="@string/version_name" > and the content of build.xml file located under res/values disrectory of my project: <?xml version="1.0" encoding="utf-8"?>