2017-07-05 7 views
-2

Ich mache ein Projekt im Android Studio, und ich brauche eine Navigationsschublade, machte ich eine Navigation, aber das Problem, ich kann es nicht schieben Sie links und rechts seinen Block ohne zu bewegen.Kann nicht Navigation Schublade schieben

slide problem

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="radiofm.arabelradio.MainActivity" 
    android:background="#e10716" 
    > 

<android.support.design.widget.NavigationView 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     app:menu="@menu/navigation_menu" 
     android:layout_gravity="start" 
     > 

    </android.support.design.widget.NavigationView> 

    <ImageButton 
     android:id="@+id/id_play" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:scaleType="fitCenter" 
     android:background="#e10716" 
     android:layout_marginBottom="84dp" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="250dp" 
     android:layout_height="100dp" 
     android:layout_marginTop="55dp" 
     app:srcCompat="@drawable/arabel" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" /> 




</RelativeLayout> 

Mein Java-Code ich ein Projekt im Android Studio machte und ich brauche eine Navigationsleiste, machte ich eine Navigation, aber das Problem kann ich es nicht schieben links und rechts sein Block ohne

public class MainActivity extends AppCompatActivity { 


    ImageButton id_play; 
    MediaPlayer mediaPlayer; 
    boolean prepared = false; 
    boolean started =false; 
    String stream ="http://arabelfm.ice.infomaniak.ch/arabelprodcastfm.mp3"; 






    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     id_play = (ImageButton) findViewById(R.id.id_play); 
     id_play.setEnabled(false); 
     //id_play.setText("LOADING"); 
     mediaPlayer = new MediaPlayer(); 
     mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
     new PlayerTask().execute(stream); 
     id_play.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       if (started){ 
        started=false; 
        mediaPlayer.pause(); 
        id_play.setImageResource(R.drawable.play); 
        // id_play.setText("PLAY"); 
       } 
       else { 
        started=true; 
        mediaPlayer.start(); 
        id_play.setImageResource(R.drawable.pause); 

        //id_play.setText("PAUSE"); 

       } 

      } 
     }); 
    } 
+0

fügen Sie Ihren Java-Code hinzu. –

+0

wo ist dein [DrawerLayout] (https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html) – kId

+0

@farhanpatel ich bearbeitet –

Antwort

0

Versuchen zu Bewegen der Logik manuell hinzufügen:

toolbar.setNavigationOnClickListener(new View.OnClickListener() { 
@Override 
public void onClick(View v) { 
    drawerLayout.openDrawer(GravityCompat.START); 
} 
}); 
Verwandte Themen