IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants graphiques Android Discussion :

Surcharger TextView problème


Sujet :

Composants graphiques Android

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2011
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2011
    Messages : 140
    Points : 38
    Points
    38
    Par défaut Surcharger TextView problème
    Bonjour,

    Je souhaite surcharger la classe TextView. Pour cela j'ai créé une classe EditDateView :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    package com.googlecode.android.widgets.DateSlider;
     
    import android.content.Context;
     
    import android.widget.TextView;
     
    public class EditDateView extends TextView {
     
     
    	public EditDateView(Context context) {
    		super(context);
    		// TODO Auto-generated constructor stub
    	}
     
    	public void changerTexte(){
     
    		this.setText("ca a change de texte");
    	}
     
     
     
    }
    Pour tester cette classe j'ai une activité de test :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
     
    /*
     * Copyright (C) 2011 Daniel Berndt - Codeus Ltd  -  DateSlider
     *
     * This is a small demo application which demonstrates the use of the
     * dateSelector
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
     
    package com.googlecode.android.widgets.DateSlider;
     
    import java.util.Calendar;
     
    import android.app.Activity;
    import android.app.Dialog;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.TextView;
     
     
    import com.googlecode.android.widgets.DateSlider.labeler.TimeLabeler;
     
    /**
     * Small Demo activity which demonstrates the use of the DateSlideSelector
     *
     * @author Daniel Berndt - Codeus Ltd
     *
     */
    public class Demo extends Activity {
     
     
        private EditDateView edv;
     
        @Override
        public void onCreate(Bundle savedInstanceState) {
            // load and initialise the Activity
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
     
     
            edv = (EditDateView) this.findViewById(R.id.edv);
            // set up a listener for when the button is pressed
            edv.setOnClickListener(new OnClickListener() {
                public void onClick(View arg0) {
                    // call the internal showDialog method using the predefined ID
                    edv.changerTexte();
                }
            });
    }
    et mon layout " main " :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
     
    <?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"
        >
     
    <com.googlecode.android.widgets.DateSlider.EditDateView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="cestcluila" android:id="@+id/edv" />
     
    </LinearLayout>
    Maintenant voici mon erreur logcat :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    09-05 09:48:56.708: ERROR/AndroidRuntime(920): Uncaught handler: thread main exiting due to uncaught exception
    09-05 09:48:56.977: ERROR/AndroidRuntime(920): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.googlecode.android.widgets.DateSlider/com.googlecode.android.widgets.DateSlider.Demo}: java.lang.ClassNotFoundException: com.googlecode.android.widgets.DateSlider.Demo in loader dalvik.system.PathClassLoader@43735ce8
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.os.Looper.loop(Looper.java:123)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread.main(ActivityThread.java:3948)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at java.lang.reflect.Method.invoke(Method.java:521)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at dalvik.system.NativeStart.main(Native Method)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920): Caused by: java.lang.ClassNotFoundException: com.googlecode.android.widgets.DateSlider.Demo in loader dalvik.system.PathClassLoader@43735ce8
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186)
    09-05 09:48:56.977: ERROR/AndroidRuntime(920):     ... 11 more
    Mon paquetage où j'ai ma classe s'apelle bien com.googlecode.android.widgets.DateSlider.

    Voilà, avez-vous des explications à mon problème ? Je vous remercie

  2. #2
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    As tu bien déclaré ton Activity "Demo" dans ton manifest ?
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

Discussions similaires

  1. surcharge operator[] problème type retour
    Par -Gesicht- dans le forum C++
    Réponses: 9
    Dernier message: 13/06/2013, 01h04
  2. [TextView] Problème de visibilité du texte en bas d'écran
    Par JQueen dans le forum Composants graphiques
    Réponses: 13
    Dernier message: 13/12/2012, 10h26
  3. TextView : Problème d'application de style
    Par JQueen dans le forum Composants graphiques
    Réponses: 5
    Dernier message: 06/12/2012, 15h09
  4. Problème de surcharge d'opérateurs
    Par Hell dans le forum C++
    Réponses: 17
    Dernier message: 17/01/2005, 16h01
  5. Réponses: 2
    Dernier message: 25/07/2004, 23h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo