I think maybe where you have

    mInfo = ((TextView) findViewById(R.string.infomation));

it is not getting a view back. Usually R.string.information would be
referring to a field like

android:id="@+id/information"

Which would be an attribute of the TextView from your layout XML
file.

You example is referring to something not a TextView ID string.

Hope this helps!

On Sep 11, 12:25 pm, Boozel <[email protected]> wrote:
> I'm trying to change the text in the text view section of a custom
> layout.
> I Just get a null pointer exception for some reason. Here is my code:
>
> package com.example.easychef;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.util.Log;
> import android.widget.TextView;
>
> public class Infomation extends Activity {
>     /** Called when the activity is first created.
>      * @param database */
>         private TextView mInfo;
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         //String []recipe=getIntent().getExtras().getStringArray
> ("db");
>         Log.i("EasyChef","Info: Ito info");
>         setContentView(R.layout.layout_i);
>        mInfo = ((TextView) findViewById(R.string.infomation));
>         try{
>         mInfo.setText("12345");
>         }
>         catch (Exception e)
>         {Log.e("EasyChef","error2: ",e);}
>     }
>
> }
>
> The error is in the catch there and is given as
> java.lang.NullPointerException
>
> This is my Layout file
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:orientation="vertical"
>     android:layout_width="fill_parent"
> android:layout_height="fill_parent" android:gravity="right">
>
>     <LinearLayout
>         android:orientation="horizontal"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent" android:layout_weight="1">
>
>         <TextView
>             android:gravity="center_horizontal"
>             android:layout_width="wrap_content"
>             android:layout_height="fill_parent"
>             android:layout_weight="1" android:textScaleX="1"
> android:text="@string/infomation"/>
>     </LinearLayout>
>
>     <LinearLayout
>         android:orientation="vertical"
>         android:layout_height="fill_parent"
>         android:layout_width="wrap_content"
> android:layout_weight="9">
>     <Button android:id="@+id/Button01"
> android:layout_height="wrap_content"
> android:layout_width="fill_parent" android:text="Prepare"></Button>
> </LinearLayout>
>
> </LinearLayout>
>
> Any help would be great
> Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to