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 :

Passage d'une activuté vers une autre en passant par la ListView


Sujet :

Composants graphiques Android

  1. #1
    Candidat au Club
    Femme Profil pro
    en stage
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : en stage

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Points : 4
    Points
    4
    Par défaut Passage d'une activuté vers une autre en passant par la ListView
    Bonjour

    Je suis debutante dans l'android .
    Je voudrais passé d'une activuté vers une autre en passant par la listview.
    Merci de m'aider.

    Voici ma page pincipale:

    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
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    package com.example.vsmobile;
     
    import java.util.ArrayList;
     
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v4.app.FragmentActivity;
    import android.support.v7.app.ActionBarActivity;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.SubMenu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.ViewGroup;
    import android.webkit.WebView;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ListView;
     
    public class MainActivity extends ActionBarActivity {
    	private Button bt;
    	private ListView lv;
    	private ArrayList <String> strArr;
    	private ArrayAdapter<String> adapter;
    	private EditText et;
     
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
     
    		bt = (Button) findViewById(R.id.button1);        
    		lv = (ListView) findViewById(R.id.listView1);
    		et = (EditText) findViewById(R.id.editText1);
    		strArr = new ArrayList<String>();
    		for (int i = 0; i < 2; i++){
    			strArr.add("Row" + i);        	
    		}
     
    		adapter = new ArrayAdapter<String>(getApplicationContext(),
    				android.R.layout.simple_list_item_1,strArr);
    		lv.setAdapter(adapter);
    		bt.setOnClickListener(new OnClickListener(){
     
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				strArr.add(et.getText().toString());
    				adapter.notifyDataSetChanged();
     
    			}
    		});
     
     
    		/*if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.container, new PlaceholderFragment())
                        .commit();
            }*/
     
    		Button listViewButton = (Button) findViewById(R.id.button1);
    		listViewButton.setOnClickListener(new OnClickListener() {
     
    		  @Override	
    		public void onClick(View v) {
    			Intent intent = new Intent(MainActivity.this,FragmentActivity.class);
    			startActivity(intent);
     
    		}
    		  });
    	}
     
     
     
     
    	@Override
    	public boolean onCreateOptionsMenu(Menu menu) {
     
    		// Inflate the menu; this adds items to the action bar if it is present.
    		//getMenuInflater().inflate(R.menu.main, menu);
     
    		menu.add(0, 0, 0, "Option1").setShortcut('3', 'c');
    		menu.add(0, 1, 0, "Option2").setShortcut('3', 'c');
    		menu.add(0, 2, 0, "Option3").setShortcut('4', 's');
     
    		for(int i = 0 ; i < 15; i++){
    			menu.add(0, 1, 0, "toto " + i);
    		}
     
     
    		SubMenu sMenu = menu.addSubMenu(0, 3, 0, "SubMenu"); //If you want to add submenu               
    		sMenu.add(0, 4, 0, "SubOption1").setShortcut('5', 'z');
    		sMenu.add(0, 5, 0, "SubOption2").setShortcut('5', 'z');             
     
    		return true;
    	}
     
    	@Override
    	public boolean onOptionsItemSelected(MenuItem item) {
    		// Handle action bar item clicks here. The action bar will
    		// automatically handle clicks on the Home/Up button, so long
    		// as you specify a parent activity in AndroidManifest.xml.
    		String title = item.getTitle().toString();
     
     
    		int id = item.getItemId();
    		if (id == R.id.action_settings) {
    			return true;
     
     
    		}
    		return super.onOptionsItemSelected(item);
    	} 
     
    	/**
             * A placeholder fragment containing a simple view.
             */
    	public static class PlaceholderFragment extends Fragment {
     
    		public PlaceholderFragment() {
    		}
     
    		@Override
    		public View onCreateView(LayoutInflater inflater, ViewGroup container,
    				Bundle savedInstanceState) {
    			View rootView = inflater.inflate(R.layout.activity_main, container, false);
    			return rootView;
    		}
    	}
     
    	public boolean shouldOverrideUrlLoading(WebView view, String url) {
    		// TODO Auto-generated method stub
    		return false;
    	}
     
    }
    Ma seconde page où je voudrais accede:
    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
     
     
    package com.example.vsmobile;
     
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.Button;
    import android.widget.EditText;
     
     
     
    public class WebviewActivity extends MainActivity {
     
    	   private EditText field;
    	   private WebView browser;
     
     
    	   @Override
    	   public boolean shouldOverrideUrlLoading(WebView view, String url) {
    	      view.loadUrl(url);
    	      return true;
    	   }
     
    	   @Override		
    	   protected void onCreate(Bundle savedInstanceState) {
    	      super.onCreate(savedInstanceState);
    	      setContentView(R.layout.fragment_main);
    	      field = (EditText)findViewById(R.id.urlField);
    	      browser = (WebView)findViewById(R.id.webView1);
    	      browser.setWebViewClient(new MyBrowser());
     
     
     
     
     
    	      // A recopier par la suite quand on voudra supprimer le bouton
    	      /* String url = field.getText().toString();
    	      browser.getSettings().setLoadsImagesAutomatically(true);
    	      browser.getSettings().setJavaScriptEnabled(true);
    	      browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    	      browser.loadUrl(url);*/
    	   }
     
     
    	   public void open(View view){
    	      String url = field.getText().toString();
    	      browser.getSettings().setLoadsImagesAutomatically(true);
    	      browser.getSettings().setJavaScriptEnabled(true);
    	      browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    	      browser.loadUrl(url);
     
    	   }
    	   private class MyBrowser extends WebViewClient {
    	      @Override
    	      public boolean shouldOverrideUrlLoading(WebView view, String url) {
    	         view.loadUrl(url);
    	         return true;
    	      }
    	   }
     
    	   @Override
    	   public boolean onCreateOptionsMenu(Menu menu) {
    	      // Inflate the menu; this adds items to the action bar if it is present.
    	      getMenuInflater().inflate(R.menu.main, menu);
    	      return true;
    	   }
     
    	}
    et mes deux 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
    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
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.vsmobile.MainActivity$PlaceholderFragment" >
     
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="Bienvenue sur vsMobile" />
     
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="26dp"
            android:ems="10" >
     
            <requestFocus />
        </EditText>
     
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/editText1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:text="Button" />
     
     
     	<ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/button1" >
     
        </ListView>
     
     
    </RelativeLayout>
    Mon deuxieme 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
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity"
        tools:ignore="MergeRootFrame" >
     
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/urlField"
            android:layout_centerHorizontal="true"
            android:onClick="open"
            android:text="browse" />
     
        <WebView
            android:id="@+id/webView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_below="@+id/button1" />
     
        <EditText
            android:id="@+id/urlField"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:ems="10" />
     
    </RelativeLayout>

  2. #2
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    273
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2013
    Messages : 273
    Points : 150
    Points
    150
    Par défaut
    tu devrai d'abord utiliser la balise [CODE] pour qu'on puisse plus facilement comprendre le code que tu nous donne ( tu clique sur le bouton "#" en haut de l'endroit ou tu tape ton texte )

  3. #3
    Candidat au Club
    Femme Profil pro
    en stage
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : en stage

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Points : 4
    Points
    4
    Par défaut
    Merci ,
    Je m'y tiendrais pour la prochaine fois.

    Tu pourrais m'aider pour ma question SVP.

  4. #4
    Membre habitué
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    273
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2013
    Messages : 273
    Points : 150
    Points
    150
    Par défaut
    Citation Envoyé par karilux Voir le message
    Je voudrais passé d'une activité vers une autre en passant par la listview.
    donc si j'ai bien compris tu veux passer a une autre activité en cliquant sur un élément de la listview ?

  5. #5
    Candidat au Club
    Femme Profil pro
    en stage
    Inscrit en
    Juillet 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : en stage

    Informations forums :
    Inscription : Juillet 2014
    Messages : 7
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par danieldou Voir le message
    donc si j'ai bien compris tu veux passer a une autre activité en cliquant sur un élément de la listview ?

    Oui c'est exactement çà.!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VB.Net] Comment copier une DataRow d'une table vers une autre ?
    Par YLF dans le forum Accès aux données
    Réponses: 7
    Dernier message: 05/09/2012, 23h23
  2. Réponses: 1
    Dernier message: 04/05/2007, 12h40
  3. copier une ligne d'une table vers une autre
    Par Adren dans le forum Langage SQL
    Réponses: 5
    Dernier message: 08/08/2006, 11h54
  4. copier une partie d'une image vers une autre
    Par gregcat dans le forum Langage
    Réponses: 1
    Dernier message: 14/04/2006, 13h39
  5. [VB.NET] Copie d'une table d'une DB vers une autre
    Par SergeF dans le forum Windows Forms
    Réponses: 9
    Dernier message: 20/11/2004, 09h54

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