Note that there are some explanatory texts on larger screens.

plurals
  1. PONull pointer exception in TextView
    primarykey
    data
    text
    <p>This is my layout </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;TextView android:id = "@+id/postQues" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Post A Question" /&gt; &lt;TextView android:id="@+id/postAnswer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:text="Post Your Answer" /&gt; &lt;Button android:id="@+id/submit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:clickable="true" android:text="Submit" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>This is my activity:</p> <pre><code>package com.qstack.quizbox; import roboguice.activity.RoboActivity; import roboguice.inject.ContentView; import roboguice.inject.InjectView; import android.content.DialogInterface; import android.view.View.OnClickListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.app.main.R; @ContentView(R.layout.q_box) public class QuizBox extends RoboActivity { @InjectView(R.id.postQues) TextView postQues; @InjectView(R.id.postAnswer) EditText postAnswer; //@InjectView(R.id.submit) Button submitA; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); PostQuestion postQuestion = new PostQuestion(); postQues.setText(postQuestion.postQuestion()); submitA.setOnClickListener(submitAnswerListener); } private OnClickListener submitAnswerListener = new OnClickListener() { //onClick view public void onClick(View v) { String answer; answer = postA.getText().toString(); CheckAnswer checkAnswer = new CheckAnswer(); if (answer == checkAnswer.checkAnswer()) { postA.setText("Correct"); } } }; } </code></pre> <p>I am getting a null pointer exception at line number 48, caused because postQues = null. When I remove postAnswer from the code, there is no null pointer exception. I've cleaned my project and all that. Any help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload