Note that there are some explanatory texts on larger screens.

plurals
  1. POLinking TextViews
    primarykey
    data
    text
    <p>While trying to manipulate a TextView box, I kept recieving null pointer errors. I have discovered that my TextView box is not linked to my code despite the fact that I have set it to the correct ID. I do not know what the problem is though. I link all my TextViews the same way and this is first time that I have had this problem. This is the part of my XML file that defines the TextView's properties.</p> <pre><code>&lt;TextView android:id="@+id/textviewH" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/imageView1" android:layout_alignTop="@+id/textView5" android:layout_marginLeft="64dp" android:text="@string/HumiumLink" /&gt; </code></pre> <p>This is my java file</p> <pre><code> AlertDialog.Builder dialog = new AlertDialog.Builder(this); View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_about_t2m, null); Tv = ((TextView) findViewById(R.id.textviewH)); if (Tv != null) { Tv.setMovementMethod(LinkMovementMethod.getInstance()); } dialog.setView(view); dialog.setTitle("About T2M"); dialog.setIcon(R.drawable.ic_launcher); dialog.setCancelable(false); dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } } ); dialog.create(); dialog.show(); </code></pre> <p>I have found that the code inside the if-statement never executes which means that Tv is null. Logcat even shows a strange error that I have not seen before. ![LogCat Error Messages][1] I circled it in blue. This is frustrating.</p> <p><strong>EDIT1:</strong></p> <p>This is all for a part of the menu called AboutT2M that is executed from the main activity. The following is the menu code from my main activity</p> <pre><code>public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.AboutMorseID: Intent AboutMorseI = new Intent(this, About_Morse.class); startActivity(AboutMorseI); break; case R.id.SettingsID: Intent SettingsI = new Intent(this, SettingsActivity.class); startActivity(SettingsI); break; case R.id.ReadMeID: Intent ReadMeI = new Intent(this, ReadMe.class); startActivity(ReadMeI); break; case R.id.AboutT2MID: Intent AboutT2MI = new Intent(this, About_T2M.class); startActivity(AboutT2MI); break; default: } return true; } </code></pre> <p>[1]: <a href="http://i.stack.imgur.com/vRH7Q.png" rel="nofollow">http://i.stack.imgur.com/vRH7Q.png</a><em>emphasized text</em></p>
    singulars
    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