Problem with textview in a Dialog

by Chavepeyer Geoffrey » Tue, 10 Mar 2009 00:45:10 GMT


Sponsored Links
 Hi everyone :)

I'm a real beginner in Android and find it really coll but I do have
one problem :

This is what I'm trying to do : set the dialog content view whos
description is in a XML file and change the value of some of those
textfield. Like this :

Dialog d = new Dialog(context);
d.setTitle(R.string.MeetingDetails);
d.setContentView(R.layout.meeting_detail);

TextView tv = (TextView) findViewById(R.id.MDDateVALUE);
tv.setText("TEST");

d.show();

and my meetind_detail.xml 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"
    >

<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/MDDate"
android:text="@string/MeetingDetailsDate"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/MDDateVALUE" ></
TextView>
</LinearLayout>


But when calling the setText(...) method on the "tv" object I got a
NullPointerException because tv is null.
I guess the view is not loaded yet and therefore the textfield doesnt
exists yet.

What am I supposed to do ?

Thanks a lot everyone for your help :)

Geoffrey.

--~--~---------~--~----~------------~-------~--~----~



Problem with textview in a Dialog

by Chavepeyer Geoffrey » Tue, 10 Mar 2009 18:30:31 GMT


 So, I've created a test case but still encounter the same problem:

package be.geoc.DialogTest;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Dialog_Test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button b = (Button) findViewById(R.id.Button01);

        b.setOnClickListener(new View.OnClickListener(){

                        public void onClick(View arg0) {
                                Dialog d = new Dialog(Dialog_Test.this);
                        d.setContentView(R.layout.meeting_detail);


                        TextView tv = (TextView) findViewById(R.id.TextView01);
                        System.out.println(tv);
                        tv.setText("TEST");

                        d.show();

                        }

        });
    }
}

And the 2 xml layout files :
main.xml :

<?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"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" android:id="@+id/TextView"/>
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Ouvrir le dialog"></
Button>
</LinearLayout>


and meeting_detail.xml :

<?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"
    >

<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>


Is anyone able to help me ?
Thanks a lot !!!

Geoffrey
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Problem with textview in a Dialog

by Chavepeyer Geoffrey » Wed, 11 Mar 2009 16:09:57 GMT


 Nobody to help me ?



On Mar 10, 11:30am, Chavepeyer Geoffrey <gchavepe...@gmail.com>


--~--~---------~--~----~------------~-------~--~----~



Problem with textview in a Dialog

by Chavepeyer Geoffrey » Thu, 12 Mar 2009 18:52:15 GMT


 ound the problem :
I needed to call the findViewById() method on the dialog like this :

TextView tv = (TextView) d.findViewById(R.id.TextView01);

and not like this :

TextView tv = (TextView) findViewById(R.id.TextView01);

Geoffrey.

On 11 mar, 09:09, Chavepeyer Geoffrey <gchavepe...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. What's wrong in my code ?

Hi All,

This is the implementation of my SurfaceView Class

@Override
        public void surfaceCreated(SurfaceHolder holder)
        {
                Log.v("My3DClass", "surfaceCreated");
                egl = (EGL10)EGLContext.getEGL();

                if(egl == null)
                        Log.v("Error","unable to load EGL");
                EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

                if(dpy == null)
                        Log.v("Error","unable to load Display");

                int[] version = new int[2];
        egl.eglInitialize(dpy, version);
        if(version[0]<1)
                Log.v("Error"," unable to initilize version ");

        int[] configSpec = {
                        EGL10.EGL_RED_SIZE, 5,
                        EGL10.EGL_GREEN_SIZE, 6,
                        EGL10.EGL_BLUE_SIZE, 5,
                //EGL10.EGL_ALPHA_SIZE, 0,
                EGL10.EGL_DEPTH_SIZE, 16,
                // EGL11.EGL_STENCIL_SIZE, EGL11.EGL_DONT_CARE,   //
don't care about stencils
                EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
                EGL10.EGL_NONE

        };
        EGLConfig[] configs = new EGLConfig[1];
        int[] num_config = new int[1];
        if(!egl.eglChooseConfig(dpy, configSpec, configs, 1,
num_config))
                Log.v("Error","unable to choose Config ");

        EGLConfig config = configs[0];
        EGLContext ctx = egl.eglCreateContext(dpy, config,
                        EGL10.EGL_NO_CONTEXT, null);
        if(ctx == null)
                Log.v("Error","unable to create context");

        EGLSurface surface = egl.eglCreateWindowSurface(dpy, config,
                        this, null);

        if(surface == null)
                Log.v("Error","unable to create surface");

        if(!egl.eglMakeCurrent(dpy, surface, surface, ctx))
                Log.v("Error","unable to make surface current");
        mEglContext = ctx;
        mEglDisplay = dpy;
        mEglSurface = surface;
        }

@Override
        public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2,
int arg3)
        {
                        gl = (GL10)mEglContext.getGL();
                        if(gl == null)
                                Log.v("Error","unable to load G L");
                        gl.glViewport(0, 0, getWidth(),getHeight());
                        gl.glDisable(GL10.GL_DITHER);
                gl.glClearColor(0,1,1,0);
                gl.glEnable(GL10.GL_SCISSOR_TEST);
                gl.glScissor(0, 0, arg2, arg3);
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

                        egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
                gl.glMatrixMode(GL10.GL_PROJECTION);
                gl.glLoadIdentity();
                GLU.gluPerspective(gl, 45f, getWidth()/getHeight(), 0.1f,
100);

                gl.glMatrixMode(GL10.GL_MODELVIEW);
                mAnimate = true;
                Draw3D();
        }

public void Draw3D()
        {
                        egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
                        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | 
GL10.GL_DEPTH_BUFFER_BIT);
                        gl.glLoadIdentity();
                        GLU.gluLookAt(gl, 0, 0, -20, 0, 0, 0, 0, 1, 0);
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
                gl.glFrontFace(GL10.GL_CCW);
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
                gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, 3,
GL10.GL_UNSIGNED_SHORT, mIndexBuffer);

                egl.eglWaitGL();
                egl.eglSwapBuffers(mEglDisplay, mEglSurface);
        }

@Override
        public void run()
{
while(true)
{
Draw3D();
}



i don't find my screen rendering... is there any problem in my code...
Please suggest...



thanks & regards,
K.Prabhakar
--~--~---------~--~----~------------~-------~--~----~

2. Porting Android to PC

Hello,

Can I run Android in a PC, if so please point me few links/steps

I understand that Dalvik is for ARM, but if the Emulator can create
A platform for Android apps to run why not we be able to run it
In a normal OS?

Is Android compiled Bytecode completely different from normal bytecode,
Where does it differ, is it the Hardware Architecture or the software?


Thanks
Arul

-----Original Message-----
From: android-porting@googlegroups.com
[EMAIL PROTECTED] On Behalf Of Markus
Sent: Monday, November 24, 2008 4:49 PM
To: android-porting
Subject: [android-porting] Re: Procedure to extract Filesystem From NewSDK


Hi,

you can extract the filesystem like in the tutorial you mentioned,
nothing changed in Android's basic file system structure.
Indeed, there are some changes in the booting process. You have to
call /init to boot Android, runtime does not exist anymore. There are
also some changes in the kernel, like the new ashmem driver, which are
required for Android.

bye
Markus






--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [EMAIL PROTECTED]
website: 

3. Eclipse repo is down?

4. "invalid data message"-error

5. Procedure to extract Filesystem From NewSDK

6. how can i reboot the device or lock the device using sdk?

7. Andriod on Sidekick