nullpointerexception

How to solve this : 'Running android lint' issue

那年仲夏 提交于 2019-12-17 23:32:54
问题 In any activity of my project, if i do some changes and then save that activity i got the message "Running android lint has encountered a problem." This is the my error log : java.lang.NullPointerException at com.android.ide.eclipse.adt.AdtUtils.workspacePathToFile(AdtUtils.java:466) at com.android.ide.eclipse.adt.internal.lint.EclipseLintClient.getClassPath(EclipseLintClient.java:753) at com.android.tools.lint.client.api.LintClient.getJavaClassFolders(LintClient.java:198) at com.android

Why is this not throwing a NullPointerException?

五迷三道 提交于 2019-12-17 21:42:53
问题 Nead clarification for following code: StringBuilder sample = new StringBuilder(); StringBuilder referToSample = sample; referToSample.append("B"); System.out.println(sample); This will print B so that proves sample and referToSample objects refer to the same memory reference. StringBuilder sample = new StringBuilder(); StringBuilder referToSample = sample; sample.append("A"); referToSample.append("B"); System.out.println(referToSample); This will print AB that also proves the same.

Why should one use Objects.requireNonNull()?

喜夏-厌秋 提交于 2019-12-17 21:25:53
问题 I have noted that many Java 8 methods in Oracle JDK use Objects.requireNonNull() , which internally throws NullPointerException if the given object (argument) is null . public static <T> T requireNonNull(T obj) { if (obj == null) throw new NullPointerException(); return obj; } But NullPointerException will be thrown anyway if a null object is dereferenced. So, why should one do this extra null check and throw NullPointerException ? One obvious answer (or benefit) is that it makes code more

How to solve NullPointerException error in Android?

我与影子孤独终老i 提交于 2019-12-17 20:50:57
问题 The below code runs smoothly in the emulator from Eclipse, but there are problems when I run it on my Android phone and tablet. public class RingerActivity extends Activity{ /** Called when the activity is first created. */ Button press; boolean tone = true; MediaPlayer mp; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mp = new MediaPlayer(); mp = MediaPlayer.create(RingerActivity.this, R.raw.alarm); //Error

Android: listview: custom items: nullpointerexception, findviewbyid returns null

不羁岁月 提交于 2019-12-17 20:33:49
问题 I have been googling and searching to resolve this error for some time and I can`t seem to find out why and how to solve it. I`m using a customAdapter to fill in my listview. I inflate the xml describing my listItem. I make viewHolder object and load in my textview using findViewById. After that i want to set the text of that textview but it findViewbyid returns a null value. So automaticcally resolving into a nullpointerexception. Adapter: /** CLASS : Custom Adapter for the listview */

findViewById returns null on a LinearLayout inside an <include>d view

蓝咒 提交于 2019-12-17 20:19:50
问题 I cannot figure out mistake here. I may be oevrlooking some thing... Layout XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:orientation="vertical" > <include android:id="@+id/headerInclude" android:layout_width="fill_parent" android:layout_height="38dp" android:layout_gravity="top" layout="@layout/header" /> <LinearLayout

IntelliJ idea gui designer + maven

限于喜欢 提交于 2019-12-17 19:33:02
问题 I have a project created with help of GUI designer. Here is code of main form. public class MainForm { MainForm() { directLineOkButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //some action } } }); crossLineOkButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //some action }); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //some action });

NullPointerException in SharedPreferences Android

懵懂的女人 提交于 2019-12-17 18:53:16
问题 My first time using sharedPreferences and i can't seem to get past this error. I have a submenu that is supposed to allow the user to set their region. This should open the correct region activity and be stored and recalled when the app is opened again. I've been going round in circles many times so some of the code will be a bit wierd. I've been focusing on changing from US (default)to UK. In the DDMS I'm getting this: 05-13 11:22:39.344: ERROR/AndroidRuntime(960): java.lang

parseSdkContent failed Could not initialize class android.graphics.Typeface

自闭症网瘾萝莉.ら 提交于 2019-12-17 18:45:34
问题 When I open layout editor, eclipse is giving this error: parseSdkContent failed Could not initialize class android.graphics.Typeface And when I try to run project, it is giving this error : An internal error occurred during: "Launching myapp". java.lang.NullPointerException Every time I'm getting this error and I have to restart eclipse. Is there any solution? This problem started suddenly today. XML file: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android

How to cast MenuItem to LinearLayout

ε祈祈猫儿з 提交于 2019-12-17 17:07:46
问题 I have NavigationView with menus. I am able to get MenuItem from navigationView by using MenuItem menuItem = navigationView.getMenu().getItem(0); LinearLayout linearLayout = (LinearLayout) menuItem; I want to cast menuItem to LinearLayout or View. I have set android:actionViewClass to menu in menu.xml : <item android:id="@+id/nav_backup" android:icon="@drawable/ic_sd_card_black_24dp" android:actionViewClass="android.widget.LinearLayout" android:title="@string/backup_configuration" /> While