0

J'ai créé des fragments (fragment 6) dans mon application. Dans mon premier fragment (android_frag) il y a un bouton "Show Places on Map" . Lorsque je clique sur ce bouton, les nouveaux noms d'activités "ShowPlace" s'ouvrent. Dans le fichier xml show_places, j'ai créé un bouton qui devrait me renvoyer à l'écran précédent, le fragment android mais le bouton n'apparait pas quand l'activité ShowPlaces apparaît, bien que je puisse voir le bouton dans la disposition graphique du fichier xml. Je n'ai pas été en mesure de trouver où le problème est.Veuillez aider.Le bouton n'apparaît pas sur l'activité qui s'ouvre à partir de Fragment, mais le bouton apparaît dans la disposition graphique

Voici mon fichier show_places.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 


<!-- Show on Map button --> 

<Button 
    android:id="@+id/btn_show_map1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="5dip" 
    android:text="@string/showplaces" 
    /> 

    </LinearLayout> 

Voici le fichier ShowPlaces.java

package com.example.tabswipe; 


import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.app.Activity; 
import android.view.Menu; 


public class ShowPlaces extends Activity implements OnClickListener { 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View ios = inflater.inflate(R.layout.show_places, container, false); 



     Button button = (Button) ios.findViewById(R.id.btn_show_map); 
      button.setOnClickListener(new OnClickListener() 
      { @Override 
       public void onClick(View v) { 
        // here you set what you want to do when user clicks your button, 
        // e.g. launch a new activity 
       Intent openStartingPoint = new Intent("com.example.tabswipe.Android"); 
        startActivity(openStartingPoint); 

       } 
      }); 
      return ios; 


    } 


public void onClick(View v) { 
    // TODO Auto-generated method stub 

} 





    } 

Répondre

0

On dirait que vous avez android: id = "@ + id/btn_show_map1" dans le fichier XML mais essayez de trouver l'ID btn_show_map. Ceux-ci devraient être changés pour être les mêmes que les autres.

+0

Merci pour votre réponse rapide ... ya..Il est comme ça seulement.. erreur de frappe lors de la publication de la question –

Questions connexes