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 :

Utilisation d'une WebView dans un ViewFlipper ?


Sujet :

Composants graphiques Android

  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2011
    Messages
    19
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2011
    Messages : 19
    Points : 13
    Points
    13
    Par défaut Utilisation d'une WebView dans un ViewFlipper ?
    Bonjour,

    Apres avoir recherche partout sur le net je n'ai pas trouve de solution concrete pour utiliser une WebView dans un ViewFlipper, j'en viens à me demander si cela est possible ?

    et si oui, comment faudrait il s'y prendre ?

    mon 1er problème réside dans l'écriture du fichier xml.
    Pour celui-ci, je m'y prends comme ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <?xml version="1.0" encoding="utf-8"?>
    <ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android" 
           android:id="@+id/ViewFlipper" 
           android:layout_width="fill_parent" 
           android:layout_height="fill_parent" >
           <include android:id="@+id/WebView1"  layout="@layout/page1" android:layout_width="match_parent" android:layout_height="match_parent"/> 
           <include android:id="@+id/Webview2" layout ="@layout/page2" android:layout_width="match_parent" android:layout_height="match_parent"/>
              </ViewFlipper>
    merci pour toute l'aide que vous pourrez me procurez

  2. #2
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2011
    Messages
    19
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2011
    Messages : 19
    Points : 13
    Points
    13
    Par défaut suite pbm WebView dans ViewFlipper
    Le viewflipper etant un composant que je maitrise avec le linearlayout.
    J'ai decider d'implémenter mon WebView à l'intérieure de celui-ci le tout dans mon ViewFlipper.
    une façon de contourner le pbm, par contre là pas de reaction sur la partie WebView
    mais sur le reste on flip bien ???....

    toute aide serai la bienvenue, merci

    voici le code xml :

    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
    <ViewFlipper
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent" android:id="@+id/flip">
        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/premiervue">
            <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="page1"></TextView>
            <WebView android:layout_width="match_parent" android:id="@+id/vueone" android:layout_height="429dp" android:layout_marginTop="100dp"></WebView>
        </LinearLayout>
        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/deuxiemevue">
            <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView2" android:text="page2"></TextView>
            <WebView android:layout_width="match_parent" android:id="@+id/vueone" android:layout_height="429dp" android:layout_marginTop="100dp"></WebView>
        </LinearLayout>
        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/troisiemvue">
            <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView3" android:text="page3"></TextView>
           <WebView android:layout_width="match_parent" android:id="@+id/vueone" android:layout_height="429dp" android:layout_marginTop="100dp"></WebView>
        </LinearLayout>
    </ViewFlipper>
    je vous met egalement le code java :


    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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    public class Test3webkitsActivity extends Activity implements OnGestureListener {
     
    	private static final int SWIPE_MIN_DISTANCE = 120;
    	private static final int SWIPE_MAX_OFF_PATH = 250;
    	private static final int SWIPE_THRESHOLD_VELOCITY = 200;
     
    	private Animation slideLeftIn;
    	private Animation slideLeftout;
    	private Animation slideRightIn;
    	private Animation slideRightout;
    	WebView webView;
     
    	private GestureDetector detector;
    	private ViewFlipper view;
     
     
     
     
    	@Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
     
     
     
     
     
     
    		/*
    		 * les différentes animations disponibles dans le repertoire anim
    		 */
    		slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_leftin);
    		slideLeftout = AnimationUtils.loadAnimation(this, R.anim.slide_leftout);
    		slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_rightin);
    		slideRightout = AnimationUtils.loadAnimation(this,
    				R.anim.slide_rightout);
     
     
    		view = (ViewFlipper) findViewById(R.id.flip);
    		detector = new GestureDetector(this, this);
    	}
     
     
     
    	/*
    	 * onTouchEvent permet de renvoyer au composant GestureDetector creer
    	 * @see android.app.Activity#onTouchEvent(android.view.MotionEvent)
    	 */
    	@Override
    	public boolean onTouchEvent(MotionEvent event) {
    		return detector.onTouchEvent(event);
    	}
     
    	/*
    	 * onFling permet d'implementer la gestion du tactile selon la position du
    	 * doight
    	 * 
    	 * @see android.view.GestureDetector.OnGestureListener#onFling(android.view.
    	 * MotionEvent, android.view.MotionEvent, float, float)
    	 */
    	@Override
    	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    			float velocityY) {
    		try {
    			if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
    				return false;
    			// right to left swipe
    			if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
    					&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
    				view.setInAnimation(slideLeftIn);
    				view.setOutAnimation(slideLeftout);
    				view.showNext();
    			} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
    					&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
    				view.setInAnimation(slideRightIn);
    				view.setOutAnimation(slideRightout);
    				view.showPrevious();
    			}
    		} catch (Exception e) {
    			Log.e("Log_tag", "Erreur switch" + e.getMessage());
    		}
    		return false;
    	}
     
    	@Override
    	public boolean onDown(MotionEvent arg0) {
    		// TODO Auto-generated method stub
    		return false;
    	}
     
    	@Override
    	public void onLongPress(MotionEvent arg0) {
     
    	}
     
    	@Override
    	public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
    			float arg3) {
    		// TODO Auto-generated method stub
    		return false;
    	}
     
    	@Override
    	public void onShowPress(MotionEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public boolean onSingleTapUp(MotionEvent arg0) {
    		// TODO Auto-generated method stub
    		return false;
    	}
     
        }

Discussions similaires

  1. [vb.net] utilisation d'une variable dans le code
    Par arnolem dans le forum Windows Forms
    Réponses: 9
    Dernier message: 30/09/2005, 19h22
  2. Utilisation d'une fonction dans une procedure
    Par MaxiMax dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 09/08/2005, 15h51
  3. Réponses: 9
    Dernier message: 05/07/2005, 08h37
  4. Utilisation d'une requete dans une requete update
    Par hellbilly dans le forum Access
    Réponses: 4
    Dernier message: 09/01/2005, 15h09
  5. Pl/SQL utilisation d'une variable dans un select
    Par larg dans le forum PL/SQL
    Réponses: 17
    Dernier message: 30/11/2004, 17h08

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